summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-05-27 05:25:53 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-05-27 05:25:53 +0000
commit9f74cbe08823afc6a6efcb1f2c2dad52a5d92e88 (patch)
tree97e670c6d3e77f302f10152cd69a63e44f2c97cb
parent6628b3608b7c30da683c03d1c18d94706f991db5 (diff)
downloadperl-MDK-Common-9f74cbe08823afc6a6efcb1f2c2dad52a5d92e88.tar
perl-MDK-Common-9f74cbe08823afc6a6efcb1f2c2dad52a5d92e88.tar.gz
perl-MDK-Common-9f74cbe08823afc6a6efcb1f2c2dad52a5d92e88.tar.bz2
perl-MDK-Common-9f74cbe08823afc6a6efcb1f2c2dad52a5d92e88.tar.xz
perl-MDK-Common-9f74cbe08823afc6a6efcb1f2c2dad52a5d92e88.zip
add addVarsInSh() and addVarsInShMode()
-rw-r--r--MDK/Common/System.pm30
1 files changed, 29 insertions, 1 deletions
diff --git a/MDK/Common/System.pm b/MDK/Common/System.pm
index 0f3dee8..c0dfbb2 100644
--- a/MDK/Common/System.pm
+++ b/MDK/Common/System.pm
@@ -110,6 +110,18 @@ restrict the fields that will be printed to LIST
like setVarsInSh with INT being the chmod value for the config file
+=item addVarsInSh(FILENAME, HASH REF)
+
+like setVarsInSh but keeping the entries in the file
+
+=item addVarsInSh(FILENAME, HASH REF, LIST)
+
+like setVarsInSh but keeping the entries in the file
+
+=item addVarsInShMode(FILENAME, INT, HASH REF, LIST)
+
+like addVarsInShMode but keeping the entries in the file
+
=item setExportedVarsInCsh(FILENAME, HASH REF, LIST)
same as C<setExportedVarsInSh> for csh format
@@ -179,7 +191,7 @@ use MDK::Common::File;
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(%compat_arch $printable_chars $sizeof_int $bitof_int arch distrib typeFromMagic list_passwd list_home list_skels list_users syscall_ psizeof availableMemory availableRamMB gettimeofday unix2dos whereis_binary getVarsFromSh setVarsInSh setVarsInShMode setExportedVarsInSh setExportedVarsInCsh template2file template2userfile read_gnomekderc update_gnomekderc fuzzy_pidofs); #);
+our @EXPORT_OK = qw(%compat_arch $printable_chars $sizeof_int $bitof_int arch distrib typeFromMagic list_passwd list_home list_skels list_users syscall_ psizeof availableMemory availableRamMB gettimeofday unix2dos whereis_binary getVarsFromSh setVarsInSh setVarsInShMode addVarsInSh addVarsInShMode setExportedVarsInSh setExportedVarsInCsh template2file template2userfile read_gnomekderc update_gnomekderc fuzzy_pidofs); #);
our %EXPORT_TAGS = (all => [ @EXPORT_OK ]);
@@ -331,6 +343,22 @@ sub getVarsFromSh {
%l;
}
+sub addVarsInSh {
+ my ($file, $l, @fields) = @_;
+ addVarsInShMode($file, 0777 ^ umask(), $l, @fields);
+}
+
+sub addVarsInShMode {
+ my ($file, $mod, $l, @fields) = @_;
+ my %l = map { $_ => $l->{$_} } @fields;
+ my %l2 = getVarsFromSh($file);
+
+ # below is add2hash_(\%l, \%l2);
+ exists $l{$_} or $l{$_} = $l2{$_} foreach keys %l2;
+
+ setVarsInShMode($file, $mod, \%l);
+}
+
sub setVarsInSh {
my ($file, $l, @fields) = @_;
setVarsInShMode($file, 0777 ^ umask(), $l, @fields);