[Fai-commit] r5333 - in trunk: bin debian
Thomas Lange
lange at alioth.debian.org
Thu Apr 16 12:22:42 UTC 2009
Author: lange
Date: 2009-04-16 12:22:42 +0000 (Thu, 16 Apr 2009)
New Revision: 5333
Modified:
trunk/bin/ainsl
trunk/debian/changelog
Log:
ainsl: add test if target file exists,
improve exit codes (closes: #500244)
Modified: trunk/bin/ainsl
===================================================================
--- trunk/bin/ainsl 2009-04-16 12:16:27 UTC (rev 5332)
+++ trunk/bin/ainsl 2009-04-16 12:22:42 UTC (rev 5333)
@@ -27,7 +27,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#*********************************************************************
-my $version = "Version 1.2.1, 3-february-2009";
+my $version = "Version 1.2.2, 16-april-2009";
use Getopt::Std;
our ($opt_a,$opt_h,$opt_D,$opt_n,$opt_s,$opt_v,$opt_q,$opt_Q);
@@ -35,6 +35,8 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub usage {
+ my $exitcode = shift;
+
print << "EOF";
ainsl, AppendIfNoSuchLine written in Perl. $version
@@ -53,7 +55,7 @@
Report bugs to <lange\@informatik.uni-koeln.de>.
EOF
- exit 0;
+ exit $exitcode;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub autocreate {
@@ -65,9 +67,9 @@
close (FILE);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-getopts('aDhsvnQq') || usage;
+getopts('aDhsvnQq') || usage(3);
-$opt_h && usage;
+$opt_h && usage(0);
$verbose = $opt_v || $ENV{verbose} || 0;
$debug = $opt_D || $ENV{debug} || 0;
@@ -75,7 +77,7 @@
$line = shift;
$optpattern = shift;
$found = 0;
-usage() unless defined $line;
+usage(3) unless defined $line;
print "FILE: $filename\nLINE: $line\nPATTERN: $pattern\n" if $debug;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -114,7 +116,7 @@
}
}
close(INFILE);
-exit 0 if $found; # nothing to append
+exit 1 if $found; # nothing to append
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Append line to file
print "ainsl: appending to $filename: $line\n" if $verbose;
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2009-04-16 12:16:27 UTC (rev 5332)
+++ trunk/debian/changelog 2009-04-16 12:22:42 UTC (rev 5333)
@@ -1,7 +1,8 @@
fai (3.2.18) UNRELEASED; urgency=low
[ Thomas Lange ]
- * ainsl: add test if target file exists
+ * ainsl: add test if target file exists,
+ improve exit codes (closes: #500244)
* fai-cd: use a pipe when sending commands to grub
* ftar, fcopy: add info about the other tool
* new file live.conf will disable some messages during booting
More information about the Fai-commit
mailing list