diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-08 07:33:45 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-08 07:33:45 +0000 |
commit | 89bca271585937793bcd07fe28ac642985ed0b6f (patch) | |
tree | 3e6a3a139a00cd6d9d56d4d8e2b093ba831f154e /coreutils | |
parent | 8936a198804850b5195249ea7732ef62fcb1d6e0 (diff) | |
download | busybox-89bca271585937793bcd07fe28ac642985ed0b6f.tar.gz |
test: recognize /path/to/[ case too
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/test.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/coreutils/test.c b/coreutils/test.c index a09f7e6ec..f86176168 100644 --- a/coreutils/test.c +++ b/coreutils/test.c @@ -182,21 +182,26 @@ static void initialize_group_array(void); int bb_test(int argc, char **argv) { int res; - - if (LONE_CHAR(argv[0], '[')) { - --argc; - if (NOT_LONE_CHAR(argv[argc], ']')) { - bb_error_msg("missing ]"); - return 2; - } - argv[argc] = NULL; - } else if (strcmp(argv[0], "[[") == 0) { - --argc; - if (strcmp(argv[argc], "]]")) { - bb_error_msg("missing ]]"); - return 2; + char *arg0; + + arg0 = strrchr(argv[0], '/'); + if (!arg0++) arg0 = argv[0]; + if (arg0[0] == '[') { + if (!arg0[1]) { /* "[" ? */ + --argc; + if (NOT_LONE_CHAR(argv[argc], ']')) { + bb_error_msg("missing ]"); + return 2; + } + argv[argc] = NULL; + } else if (LONE_CHAR(arg0, '[') == 0) { /* "[[" ? */ + --argc; + if (strcmp(argv[argc], "]]") != 0) { + bb_error_msg("missing ]]"); + return 2; + } + argv[argc] = NULL; } - argv[argc] = NULL; } res = setjmp(leaving); |