summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-03-31 14:36:44 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-03-31 14:36:44 +0000
commit2420ddc687f501b4260fe67d275c6de26196b54b (patch)
tree23244ce05112d93516dab5d808b74f745157f2cb
parent61d509733ea88bfbc2651985174a91acad970075 (diff)
downloadurpmi-2420ddc687f501b4260fe67d275c6de26196b54b.tar
urpmi-2420ddc687f501b4260fe67d275c6de26196b54b.tar.gz
urpmi-2420ddc687f501b4260fe67d275c6de26196b54b.tar.bz2
urpmi-2420ddc687f501b4260fe67d275c6de26196b54b.tar.xz
urpmi-2420ddc687f501b4260fe67d275c6de26196b54b.zip
- urpmf:
o check usage of -a, -! and the like instead of displaying the ugly "Internal error: syntax error ..."
-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') {