summaryrefslogtreecommitdiffstats
path: root/MDK
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-08-12 19:32:54 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-08-12 19:32:54 +0000
commitfbb5738194e9c892892b0d27029a0fa31cc68b57 (patch)
treea552fb74dfd0e79fa4ccb2870c62b989693da710 /MDK
parentf5e651fb4603ec1caaabd976e4088e60156c8fdd (diff)
downloadperl-MDK-Common-fbb5738194e9c892892b0d27029a0fa31cc68b57.tar
perl-MDK-Common-fbb5738194e9c892892b0d27029a0fa31cc68b57.tar.gz
perl-MDK-Common-fbb5738194e9c892892b0d27029a0fa31cc68b57.tar.bz2
perl-MDK-Common-fbb5738194e9c892892b0d27029a0fa31cc68b57.tar.xz
perl-MDK-Common-fbb5738194e9c892892b0d27029a0fa31cc68b57.zip
- add setExportedVarsInSh and setExportedVarsInCsh
- remove setVarsInCsh (obsoleted by setExportedVarsInCsh)
Diffstat (limited to 'MDK')
-rw-r--r--MDK/Common/System.pm28
1 files changed, 18 insertions, 10 deletions
diff --git a/MDK/Common/System.pm b/MDK/Common/System.pm
index f196e83..f4c1491 100644
--- a/MDK/Common/System.pm
+++ b/MDK/Common/System.pm
@@ -101,9 +101,9 @@ restrict the fields that will be printed to LIST
like setVarsInSh with INT being the chmod value for the config file
-=item setVarsInCsh(FILENAME, HASH REF, LIST)
+=item setExportedVarsInCsh(FILENAME, HASH REF, LIST)
-same as C<setVarsInSh> for csh format
+same as C<setExportedVarsInSh> for csh format
=item template2file(FILENAME_IN, FILENAME_OUT, HASH)
@@ -163,7 +163,7 @@ use MDK::Common::File;
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK %compat_arch $printable_chars $sizeof_int $bitof_int); #);
@ISA = qw(Exporter);
-@EXPORT_OK = qw(%compat_arch $printable_chars $sizeof_int $bitof_int arch typeFromMagic list_passwd list_home list_skels syscall_ psizeof availableMemory availableRamMB gettimeofday unix2dos getVarsFromSh setVarsInSh setVarsInShMode setVarsInCsh template2file template2userfile update_gnomekderc fuzzy_pidofs); #);
+@EXPORT_OK = qw(%compat_arch $printable_chars $sizeof_int $bitof_int arch typeFromMagic list_passwd list_home list_skels syscall_ psizeof availableMemory availableRamMB gettimeofday unix2dos getVarsFromSh setVarsInSh setVarsInShMode setExportedVarsInSh setExportedVarsInCsh template2file template2userfile update_gnomekderc fuzzy_pidofs); #);
%EXPORT_TAGS = (all => [ @EXPORT_OK ]);
@@ -299,19 +299,27 @@ sub setVarsInShMode {
my ($file, $mod, $l, @fields) = @_;
@fields = keys %$l unless @fields;
- local *F;
- open F, "> $file" or die "cannot create config file $file";
+ MDK::Common::File::output($file,
+ map { $l->{$_} ? "$_=$l->{$_}\n" : () } @fields
+ );
chmod $mod, $file;
- $l->{$_} and print F "$_=$l->{$_}\n" foreach @fields;
}
-sub setVarsInCsh {
+sub setExportedVarsInSh {
my ($file, $l, @fields) = @_;
@fields = keys %$l unless @fields;
- local *F;
- open F, "> $_[0]" or die "cannot create config file $file";
- $l->{$_} and print F "setenv $_ $l->{$_}\n" foreach @fields;
+ MDK::Common::File::output($file,
+ (map { $l->{$_} ? "$_=$l->{$_}\n" : () } @fields),
+ @fields ? "export " . join(" ", @fields) . "\n" : (),
+ );
+}
+
+sub setExportedVarsInCsh {
+ my ($file, $l, @fields) = @_;
+ @fields = keys %$l unless @fields;
+
+ MDK::Common::File::output($file, map { $l->{$_} ? "setenv $_ $l->{$_}\n" : () } @fields);
}
sub template2file {