summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--urpm/args.pm29
-rwxr-xr-xurpmf3
3 files changed, 26 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index acfe53a7..ca8fa964 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@
- urpmi.addmedia:
o --mirrorlist: if the retrieved media.cfg is broken, try another mirror
(#39591, it also workarounds #39592)
+- urpmf:
+ o check usage of -a, -! and the like instead of displaying the ugly
+ "Internal error: syntax error ..."
Version 5.17 - 28 March 2008, by Pascal "Pixel" Rigaux
diff --git a/urpm/args.pm b/urpm/args.pm
index 38ead349..d7acf2f8 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -205,13 +205,14 @@ my %options_spec = (
f => sub { $::full = 1 },
'F=s' => sub { $::separator = $_[1] },
'e=s' => sub { $::expr .= "($_[1])" },
- a => sub { add_urpmf_binary_op('&&') },
- o => sub { add_urpmf_binary_op('||') },
+ a => sub { add_urpmf_binary_op('&&', '-a') },
+ o => sub { add_urpmf_binary_op('||', '-o') },
'<>' => sub {
my $p = shift;
if ($p =~ /^-?([!()])$/) {
# This is for -! -( -)
- add_urpmf_unary_op($1);
+ my $op = $1;
+ $op eq ')' ? add_urpmf_close_paren() : add_urpmf_unary_op($op);
}
elsif ($p =~ /^--?(.+)/) {
# unrecognized option
@@ -354,15 +355,27 @@ sub add_urpmf_cmdline_tags {
}
}
+sub _current_urpmf_left_expr() {
+ my $left = $::left_expr || $::expr && "$::expr || " || '';
+ $::left_expr = $::expr = undef;
+ $left;
+}
+
sub add_urpmf_binary_op {
- my ($op) = @_;
+ my ($op, $cmdline) = @_;
+ $::left_expr and $urpm->{fatal}(1, N("unexpected expression %s", $::left_expr));
+ $::expr or $urpm->{fatal}(1, N("missing expression before %s", $cmdline));
- $::expr .= " $op ";
+ ($::expr, $::left_expr) = (undef, $::expr . " $op ");
}
sub add_urpmf_unary_op {
my ($op) = @_;
-
- $::expr .= $op;
+ $::expr and $urpm->{fatal}(1, N("unexpected expression %s (suggestion: use -a or -o ?)", $::expr));
+ ($::expr, $::left_expr) = (undef, $::left_expr . $op);
+}
+sub add_urpmf_close_paren() {
+ $::expr or $urpm->{fatal}(1, N("no expression to close"));
+ $::expr .= ')';
}
sub add_urpmf_parameter {
my ($p) = @_;
@@ -375,7 +388,7 @@ sub add_urpmf_parameter {
# quote "+" chars for packages with + in their names
$p =~ s/\+/\\+/g;
}
- $::expr .= ($::expr ? ' || ' : '') . "m{$p}" . $::pattern;
+ $::expr = _current_urpmf_left_expr() . "m{$p}" . $::pattern;
}
# common options setup
diff --git a/urpmf b/urpmf
index 1b3447c6..31fb499d 100755
--- a/urpmf
+++ b/urpmf
@@ -145,11 +145,12 @@ our $uniq = ''; # --uniq
our $update = 0; # --update
#- globals used in callback
-our $expr; # regexp to match against
+our ($expr, $left_expr); # regexp to match against
our %uniq;
#- parse arguments list.
my $urpm = urpm->new_parse_cmdline or exit(1);
+defined $left_expr and $urpm->{fatal}(1, N("unterminated expression (%s)", $left_expr));
defined $expr or usage();
if ($qf eq '%default') {