summaryrefslogtreecommitdiffstats
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
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)
-rw-r--r--MDK/Common/System.pm28
-rw-r--r--perl-MDK-Common.spec6
2 files changed, 23 insertions, 11 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 {
diff --git a/perl-MDK-Common.spec b/perl-MDK-Common.spec
index 9d922b9..58db97d 100644
--- a/perl-MDK-Common.spec
+++ b/perl-MDK-Common.spec
@@ -2,7 +2,7 @@
# do not change the version here, change in MDK/Common.pm.pl
%define version THEVERSION
-%define release 11mdk
+%define release 12mdk
Summary: Various simple functions
Name: perl-MDK-Common
@@ -49,6 +49,10 @@ rm -rf $RPM_BUILD_ROOT
# MODIFY IN THE CVS: cvs.mandrakesoft.com:/cooker soft/perl-MDK-Common
%changelog
+* Mon Aug 12 2002 Pixel <pixel@mandrakesoft.com> 1.0.3-12mdk
+- add setExportedVarsInSh and setExportedVarsInCsh
+- remove setVarsInCsh (obsoleted by setExportedVarsInCsh)
+
* Wed Jul 31 2002 Pixel <pixel@mandrakesoft.com> 1.0.3-11mdk
- File.pm: add "append_to_file"
- perl_checker: a few more stricter rules