summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/test.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmd/test.c b/cmd/test.c
index f0645ef98f1..0d0f090386c 100644
--- a/cmd/test.c
+++ b/cmd/test.c
@@ -71,10 +71,17 @@ static int do_test(struct cmd_tbl *cmdtp, int flag, int argc,
argc--;
}
- /* args? */
- if (argc < 3)
+ /*
+ * Per POSIX, 'test' with 0 arguments should return 1, while
+ * 'test <arg>' should be equivalent to 'test -n <arg>',
+ * i.e. true if and only if <arg> is not empty.
+ */
+ if (argc < 2)
return 1;
+ if (argc == 2)
+ return !strcmp(argv[1], "");
+
#ifdef DEBUG
{
debug("test(%d):", argc);