From 7f18ff576b64f271672ee70b1847281066cd649a Mon Sep 17 00:00:00 2001 From: freesource Date: Mon, 22 Oct 2001 17:07:37 +0000 Subject: [PATCH] This fixes undef values when scripts was called more than once when used with -qf and --scripts and -d|-l and -T. --- SWIM/Info.pm | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/SWIM/Info.pm b/SWIM/Info.pm index 5cf9d8e..3775d80 100644 --- a/SWIM/Info.pm +++ b/SWIM/Info.pm @@ -47,79 +47,83 @@ sub scripts { print "swim: no scripts for not-installed, consider --diff\n"; exit; } + # no sense going on if $argument doesn't have a value, at this point + # scripts has already been called once. --freesource + return if !$argument; + dbi(\%commands); - if ($argument =~ /_/) { - $orig_argument = $argument; - my $check = $db{"$argument"}; - $argument =~ m,(^.*)_(.*$),; - if (defined $check) { - $argument = $1; - } - else {}; - } - untie %db; + if ($argument =~ /_/) { + $orig_argument = $argument; + my $check = $db{"$argument"}; + $argument =~ m,(^.*)_(.*$),; + if (defined $check) { + $argument = $1; + } + else {}; + } + untie %db; # here we will print out whatever we find including the file name. if ($commands->{"scripts"} && !($commands->{"preinst"} || $commands->{"postinst"} || $commands->{"prerm"} || $commands->{"postrm"} || $commands->{"config"} || $commands->{"templates"})) { - if (defined "$parent$base/info/$argument.preinst") { + if (-e "$parent$base/info/$argument.preinst") { $preinst = "$parent$base/info/$argument.preinst"; } - if (defined "$parent$base/info/$argument.postinst") { + if (-e "$parent$base/info/$argument.postinst") { $postinst = "$parent$base/info/$argument.postinst"; } - if (defined "$parent$base/info/$argument.prerm") { + if (-e "$parent$base/info/$argument.prerm") { $prerm = "$parent$base/info/$argument.prerm"; } - if (defined "$parent$base/info/$argument.postrm") { + if (-e "$parent$base/info/$argument.postrm") { $postrm = "$parent$base/info/$argument.postrm"; } - if (defined "$parent$base/info/$argument.config") { + if (-e "$parent$base/info/$argument.config") { $config = "$parent$base/info/$argument.config"; } - if (defined "$parent$base/info/$argument.templates") { + if (-e "$parent$base/info/$argument.templates") { $templates = "$parent$base/info/$argument.templates"; } - if (-e $preinst) { + if ($preinst and -e $preinst) { print "#####$argument.preinst#####\n\n"; open (LIST,"$preinst"); while () { print $_; } } - if (-e $postinst) { + if ($postinst and -e $postinst) { print "#####$argument.postinst#####\n\n"; open (LIST,"$postinst"); while () { print $_; } } - if (-e $prerm) { + if ($prerm and -e $prerm) { open (LIST,"$prerm"); print "#####$argument.prerm#####\n\n"; while () { print $_; } } - if (-e $postrm) { + if ($postrm and -e $postrm) { open (LIST,"$postrm"); print "#####$argument.postrm#####\n\n"; while () { print $_; } } - if (-e $config) { + if ($config and -e $config) { open (LIST,"$config"); print "#####$argument.config#####\n\n"; while () { print $_; } } - if (-e $templates) { + if ($templates and -e $templates) { open (LIST,"$templates"); print "#####$argument.templates#####\n\n"; while () {