diff options
Diffstat (limited to 'commands/test.c')
-rw-r--r-- | commands/test.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/commands/test.c b/commands/test.c index 9070e49074..86636de1c2 100644 --- a/commands/test.c +++ b/commands/test.c @@ -40,6 +40,8 @@ typedef enum { OPT_DIRECTORY, OPT_FILE, OPT_EXISTS, + OPT_BLOCK, + OPT_CHAR, OPT_SYMBOLIC_LINK, OPT_MAX, } test_opts; @@ -60,6 +62,8 @@ static char *test_options[] = { [OPT_FILE] = "-f", [OPT_DIRECTORY] = "-d", [OPT_EXISTS] = "-e", + [OPT_BLOCK] = "-b", + [OPT_CHAR] = "-c", [OPT_SYMBOLIC_LINK] = "-L", }; @@ -142,6 +146,8 @@ static int do_test(int argc, char *argv[]) case OPT_FILE: case OPT_DIRECTORY: case OPT_EXISTS: + case OPT_BLOCK: + case OPT_CHAR: case OPT_SYMBOLIC_LINK: adv = 2; if (left < 2) @@ -169,6 +175,14 @@ static int do_test(int argc, char *argv[]) expr = 1; break; } + if (opt == OPT_BLOCK && S_ISBLK(statbuf.st_mode)) { + expr = 1; + break; + } + if (opt == OPT_CHAR && S_ISCHR(statbuf.st_mode)) { + expr = 1; + break; + } } break; |