diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-06 15:30:27 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-06 15:30:27 +0000 |
commit | dddfaff36354050d170bcc1d1328cc23e5b0065e (patch) | |
tree | 23e11e5fdf0e1f8330ccf19fe427df64728d1188 | |
parent | 380bcfc9f7ce8a979aa6ec16b15e586c65c8f3aa (diff) | |
download | busybox-w32-dddfaff36354050d170bcc1d1328cc23e5b0065e.tar.gz busybox-w32-dddfaff36354050d170bcc1d1328cc23e5b0065e.tar.bz2 busybox-w32-dddfaff36354050d170bcc1d1328cc23e5b0065e.zip |
ash: make set -o and set +o work as in dash/bash.
by Cristian Ionescu-Idbohrn.
function old new delta
options 565 625 +60
getoptscmd 709 698 -11
-rw-r--r-- | shell/ash.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c index 80241381b..200e2d4a3 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -9486,7 +9486,7 @@ setparam(char **argv) | |||
9486 | * Oh well. Let's mimic that. | 9486 | * Oh well. Let's mimic that. |
9487 | */ | 9487 | */ |
9488 | static int | 9488 | static int |
9489 | minus_o(char *name, int val) | 9489 | plus_minus_o(char *name, int val) |
9490 | { | 9490 | { |
9491 | int i; | 9491 | int i; |
9492 | 9492 | ||
@@ -9497,13 +9497,15 @@ minus_o(char *name, int val) | |||
9497 | return 0; | 9497 | return 0; |
9498 | } | 9498 | } |
9499 | } | 9499 | } |
9500 | ash_msg("illegal option -o %s", name); | 9500 | ash_msg("illegal option %co %s", val ? '-' : '+', name); |
9501 | return 1; | 9501 | return 1; |
9502 | } | 9502 | } |
9503 | out1str("Current option settings\n"); | ||
9504 | for (i = 0; i < NOPTS; i++) | 9503 | for (i = 0; i < NOPTS; i++) |
9505 | out1fmt("%-16s%s\n", optnames(i), | 9504 | if (val) { |
9506 | optlist[i] ? "on" : "off"); | 9505 | out1fmt("%-16s%s\n", optnames(i), optlist[i] ? "on" : "off"); |
9506 | } else { | ||
9507 | out1fmt("set %co %s\n", optlist[i] ? '-' : '+', optnames(i)); | ||
9508 | } | ||
9507 | return 0; | 9509 | return 0; |
9508 | } | 9510 | } |
9509 | static void | 9511 | static void |
@@ -9517,7 +9519,7 @@ setoption(int flag, int val) | |||
9517 | return; | 9519 | return; |
9518 | } | 9520 | } |
9519 | } | 9521 | } |
9520 | ash_msg_and_raise_error("illegal option -%c", flag); | 9522 | ash_msg_and_raise_error("illegal option %c%c", val ? '-' : '+', flag); |
9521 | /* NOTREACHED */ | 9523 | /* NOTREACHED */ |
9522 | } | 9524 | } |
9523 | static int | 9525 | static int |
@@ -9555,7 +9557,7 @@ options(int cmdline) | |||
9555 | if (c == 'c' && cmdline) { | 9557 | if (c == 'c' && cmdline) { |
9556 | minusc = p; /* command is after shell args */ | 9558 | minusc = p; /* command is after shell args */ |
9557 | } else if (c == 'o') { | 9559 | } else if (c == 'o') { |
9558 | if (minus_o(*argptr, val)) { | 9560 | if (plus_minus_o(*argptr, val)) { |
9559 | /* it already printed err message */ | 9561 | /* it already printed err message */ |
9560 | return 1; /* error */ | 9562 | return 1; /* error */ |
9561 | } | 9563 | } |