# Pass it an array containing the arguments of a shell command like would
# be run by exec(). It turns that into a line like you might enter at the
-# shell, escaping metacharacters and quoting qrguments that contain spaces.
+# shell, escaping metacharacters and quoting arguments that contain spaces.
sub escape_shell {
my @args=@_;
my $line="";
my $ext=pkgext($package);
my $substvarfile="debian/${ext}substvars";
my $str=$deppackage;
- $str.=" ($verinfo)" if length $verinfo;
+ $str.=" ($verinfo)" if defined $verinfo && length $verinfo;
# Figure out what the line will look like, based on what's there
# now, and what we're to add or remove.
}
}
-# Reads in the specified file, one word at a time, and returns an array of
-# the result. If a value is passed in as the second parameter, then glob
+# Reads in the specified file, one line at a time. splits on words,
+# and returns an array of arrays of the contents.
+# If a value is passed in as the second parameter, then glob
# expansion is done in the directory specified by the parameter ("." is
# frequently a good choice).
-sub filearray {
+sub filedoublearray {
my $file=shift;
my $globdir=shift;
my @ret;
open (DH_FARRAY_IN, $file) || error("cannot read $file: $1");
while (<DH_FARRAY_IN>) {
+ my @line;
# Only do glob expansion in v3 mode.
#
# The tricky bit is that the glob expansion is done
if (defined $globdir && ! compat(2)) {
for (map { glob "$globdir/$_" } split) {
s#^$globdir/##;
- push @ret, $_;
+ push @line, $_;
}
}
else {
- push @ret, split;
+ @line = split;
}
+ push @ret, [@line];
}
close DH_FARRAY_IN;
return @ret;
}
+# Reads in the specified file, one word at a time, and returns an array of
+# the result. Can do globbing as does filedoublearray.
+sub filearray {
+ return map { @$_ } filedoublearray(@_);
+}
+
# Passed a filename, returns true if -X says that file should be excluded.
sub excludefile {
my $filename = shift;