All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
Turned out unexapectedly subtle.
* Added support for vcsh, enable with: include = cat /usr/share/mr/vcsh
Thanks, Richard Hartmann
* Block tty control codes in untrusted mr config files.
* Added support for vcsh, enable with: include = cat /usr/share/mr/vcsh
Thanks, Richard Hartmann
* Block tty control codes in untrusted mr config files.
- * Show the line when failing to parse a config file. Closes: #650952
+ * Correct printing of line numbers when includes are used. Closes: #650952
-- Joey Hess <joeyh@debian.org> Tue, 29 Nov 2011 18:15:51 -0400
-- Joey Hess <joeyh@debian.org> Tue, 29 Nov 2011 18:15:51 -0400
close $in unless ref $f eq 'GLOB';
my $section;
close $in unless ref $f eq 'GLOB';
my $section;
+
+ # Keep track of the current line in the config file;
+ # when a file is included track the current line from the include.
+ my $included=undef;
+ my $includeline=0;
+ my $nextline = sub {
+ if ($included) {
+ $includeline++;
+ $included--;
+ }
+ else {
+ $included=undef;
+ $includeline=0;
+ $line++;
+ }
+ my $l=shift @lines;
+ chomp $l;
+ return $l
+ };
+ my $lineerror = sub {
+ my $msg=shift;
+ if (defined $included) {
+ die "mr: $f line $line include line $includeline: $msg\n";
+ }
+ else {
+ die "mr: $f line $line: $msg\n";
+ }
+ };
+
- $_=shift @lines;
- $line++;
- chomp;
if (! $trusted && /[[:cntrl:]]/) {
trusterror("mr: illegal control character", $f, $line, $bootstrap_url);
if (! $trusted && /[[:cntrl:]]/) {
trusterror("mr: illegal control character", $f, $line, $bootstrap_url);
# continued value
while (@lines && $lines[0]=~/^\s(.+)/) {
# continued value
while (@lines && $lines[0]=~/^\s(.+)/) {
- shift(@lines);
- $line++;
$value.="\n$1";
chomp $value;
$value.="\n$1";
chomp $value;
if ($parameter eq "include") {
print "mr: including output of \"$value\"\n" if $verbose;
if ($parameter eq "include") {
print "mr: including output of \"$value\"\n" if $verbose;
- unshift @lines, `$value`;
if ($?) {
print STDERR "mr: include command exited nonzero ($?)\n";
}
if ($?) {
print STDERR "mr: include command exited nonzero ($?)\n";
}
+ $included += @inc;
+ unshift @lines, @inc;
next;
}
if (! defined $section) {
next;
}
if (! defined $section) {
- die "$f line $.: parameter ($parameter) not in section\n";
+ $lineerror->("parameter ($parameter) not in section");
}
if ($section eq 'ALIAS') {
$alias{$parameter}=$value;
}
if ($section eq 'ALIAS') {
$alias{$parameter}=$value;
- die "$f line $line: '$_': parse error\n";
+ $lineerror->("parse error");