diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-05 00:24:52 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-05 00:24:52 +0000 |
commit | 3af3e5b4b0d12dffbe7bd144092f8cb140ff74a4 (patch) | |
tree | 39ec6b9bd83c2c27d210431f80d79b0683b32f6d | |
parent | 940494f81392bf24f4065040800aa4e58fcdb9dd (diff) | |
download | busybox-w32-3af3e5b4b0d12dffbe7bd144092f8cb140ff74a4.tar.gz busybox-w32-3af3e5b4b0d12dffbe7bd144092f8cb140ff74a4.tar.bz2 busybox-w32-3af3e5b4b0d12dffbe7bd144092f8cb140ff74a4.zip |
ash: cosmetic improvements in error messages
-rw-r--r-- | shell/ash.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/shell/ash.c b/shell/ash.c index 335dcbab1..f32c31180 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -985,9 +985,10 @@ ash_vmsg(const char *msg, va_list ap) | |||
985 | { | 985 | { |
986 | fprintf(stderr, "%s: ", arg0); | 986 | fprintf(stderr, "%s: ", arg0); |
987 | if (commandname) { | 987 | if (commandname) { |
988 | const char *fmt = (!iflag || parsefile->fd) ? | 988 | if (strcmp(arg0, commandname)) |
989 | "%s: %d: " : "%s: "; | 989 | fprintf(stderr, "%s: ", commandname); |
990 | fprintf(stderr, fmt, commandname, startlinno); | 990 | if (!iflag || parsefile->fd) |
991 | fprintf(stderr, "line %d: ", startlinno); | ||
991 | } | 992 | } |
992 | vfprintf(stderr, msg, ap); | 993 | vfprintf(stderr, msg, ap); |
993 | outcslow('\n', stderr); | 994 | outcslow('\n', stderr); |
@@ -1518,13 +1519,13 @@ nextopt(const char *optstring) | |||
1518 | c = *p++; | 1519 | c = *p++; |
1519 | for (q = optstring; *q != c; ) { | 1520 | for (q = optstring; *q != c; ) { |
1520 | if (*q == '\0') | 1521 | if (*q == '\0') |
1521 | ash_msg_and_raise_error("Illegal option -%c", c); | 1522 | ash_msg_and_raise_error("illegal option -%c", c); |
1522 | if (*++q == ':') | 1523 | if (*++q == ':') |
1523 | q++; | 1524 | q++; |
1524 | } | 1525 | } |
1525 | if (*++q == ':') { | 1526 | if (*++q == ':') { |
1526 | if (*p == '\0' && (p = *argptr++) == NULL) | 1527 | if (*p == '\0' && (p = *argptr++) == NULL) |
1527 | ash_msg_and_raise_error("No arg for -%c option", c); | 1528 | ash_msg_and_raise_error("no arg for -%c option", c); |
1528 | optionarg = p; | 1529 | optionarg = p; |
1529 | p = NULL; | 1530 | p = NULL; |
1530 | } | 1531 | } |
@@ -3426,7 +3427,7 @@ static void | |||
3426 | xtcsetpgrp(int fd, pid_t pgrp) | 3427 | xtcsetpgrp(int fd, pid_t pgrp) |
3427 | { | 3428 | { |
3428 | if (tcsetpgrp(fd, pgrp)) | 3429 | if (tcsetpgrp(fd, pgrp)) |
3429 | ash_msg_and_raise_error("Cannot set tty process group (%m)"); | 3430 | ash_msg_and_raise_error("cannot set tty process group (%m)"); |
3430 | } | 3431 | } |
3431 | 3432 | ||
3432 | /* | 3433 | /* |
@@ -3512,7 +3513,7 @@ killcmd(int argc, char **argv) | |||
3512 | if (argc <= 1) { | 3513 | if (argc <= 1) { |
3513 | usage: | 3514 | usage: |
3514 | ash_msg_and_raise_error( | 3515 | ash_msg_and_raise_error( |
3515 | "Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or\n" | 3516 | "usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or\n" |
3516 | "kill -l [exitstatus]" | 3517 | "kill -l [exitstatus]" |
3517 | ); | 3518 | ); |
3518 | } | 3519 | } |
@@ -4472,7 +4473,7 @@ forkchild(struct job *jp, union node *n, int mode) | |||
4472 | if (jp->nprocs == 0) { | 4473 | if (jp->nprocs == 0) { |
4473 | close(0); | 4474 | close(0); |
4474 | if (open(bb_dev_null, O_RDONLY) != 0) | 4475 | if (open(bb_dev_null, O_RDONLY) != 0) |
4475 | ash_msg_and_raise_error("Can't open %s", bb_dev_null); | 4476 | ash_msg_and_raise_error("can't open %s", bb_dev_null); |
4476 | } | 4477 | } |
4477 | } | 4478 | } |
4478 | if (!oldlvl && iflag) { | 4479 | if (!oldlvl && iflag) { |
@@ -4533,7 +4534,7 @@ forkshell(struct job *jp, union node *n, int mode) | |||
4533 | TRACE(("Fork failed, errno=%d", errno)); | 4534 | TRACE(("Fork failed, errno=%d", errno)); |
4534 | if (jp) | 4535 | if (jp) |
4535 | freejob(jp); | 4536 | freejob(jp); |
4536 | ash_msg_and_raise_error("Cannot fork"); | 4537 | ash_msg_and_raise_error("cannot fork"); |
4537 | } | 4538 | } |
4538 | if (pid == 0) | 4539 | if (pid == 0) |
4539 | forkchild(jp, n, mode); | 4540 | forkchild(jp, n, mode); |
@@ -4699,7 +4700,7 @@ openhere(union node *redir) | |||
4699 | size_t len = 0; | 4700 | size_t len = 0; |
4700 | 4701 | ||
4701 | if (pipe(pip) < 0) | 4702 | if (pipe(pip) < 0) |
4702 | ash_msg_and_raise_error("Pipe call failed"); | 4703 | ash_msg_and_raise_error("pipe call failed"); |
4703 | if (redir->type == NHERE) { | 4704 | if (redir->type == NHERE) { |
4704 | len = strlen(redir->nhere.doc->narg.text); | 4705 | len = strlen(redir->nhere.doc->narg.text); |
4705 | if (len <= PIPESIZE) { | 4706 | if (len <= PIPESIZE) { |
@@ -4785,9 +4786,9 @@ openredirect(union node *redir) | |||
4785 | 4786 | ||
4786 | return f; | 4787 | return f; |
4787 | ecreate: | 4788 | ecreate: |
4788 | ash_msg_and_raise_error("cannot create %s: %s", fname, errmsg(errno, "Directory nonexistent")); | 4789 | ash_msg_and_raise_error("cannot create %s: %s", fname, errmsg(errno, "nonexistent directory")); |
4789 | eopen: | 4790 | eopen: |
4790 | ash_msg_and_raise_error("cannot open %s: %s", fname, errmsg(errno, "No such file")); | 4791 | ash_msg_and_raise_error("cannot open %s: %s", fname, errmsg(errno, "no such file")); |
4791 | } | 4792 | } |
4792 | 4793 | ||
4793 | /* | 4794 | /* |
@@ -5312,7 +5313,7 @@ evalbackcmd(union node *n, struct backcmd *result) | |||
5312 | struct job *jp; | 5313 | struct job *jp; |
5313 | 5314 | ||
5314 | if (pipe(pip) < 0) | 5315 | if (pipe(pip) < 0) |
5315 | ash_msg_and_raise_error("Pipe call failed"); | 5316 | ash_msg_and_raise_error("pipe call failed"); |
5316 | jp = makejob(n, 1); | 5317 | jp = makejob(n, 1); |
5317 | if (forkshell(jp, n, FORK_NOJOB) == 0) { | 5318 | if (forkshell(jp, n, FORK_NOJOB) == 0) { |
5318 | FORCE_INT_ON; | 5319 | FORCE_INT_ON; |
@@ -7790,7 +7791,7 @@ evalpipe(union node *n, int flags) | |||
7790 | if (lp->next) { | 7791 | if (lp->next) { |
7791 | if (pipe(pip) < 0) { | 7792 | if (pipe(pip) < 0) { |
7792 | close(prevfd); | 7793 | close(prevfd); |
7793 | ash_msg_and_raise_error("Pipe call failed"); | 7794 | ash_msg_and_raise_error("pipe call failed"); |
7794 | } | 7795 | } |
7795 | } | 7796 | } |
7796 | if (forkshell(jp, lp->n, n->npipe.backgnd) == 0) { | 7797 | if (forkshell(jp, lp->n, n->npipe.backgnd) == 0) { |
@@ -8953,13 +8954,13 @@ setinputfile(const char *fname, int flags) | |||
8953 | if (fd < 0) { | 8954 | if (fd < 0) { |
8954 | if (flags & INPUT_NOFILE_OK) | 8955 | if (flags & INPUT_NOFILE_OK) |
8955 | goto out; | 8956 | goto out; |
8956 | ash_msg_and_raise_error("Can't open %s", fname); | 8957 | ash_msg_and_raise_error("can't open %s", fname); |
8957 | } | 8958 | } |
8958 | if (fd < 10) { | 8959 | if (fd < 10) { |
8959 | fd2 = copyfd(fd, 10); | 8960 | fd2 = copyfd(fd, 10); |
8960 | close(fd); | 8961 | close(fd); |
8961 | if (fd2 < 0) | 8962 | if (fd2 < 0) |
8962 | ash_msg_and_raise_error("Out of file descriptors"); | 8963 | ash_msg_and_raise_error("out of file descriptors"); |
8963 | fd = fd2; | 8964 | fd = fd2; |
8964 | } | 8965 | } |
8965 | setinputfd(fd, flags & INPUT_PUSH_FILE); | 8966 | setinputfd(fd, flags & INPUT_PUSH_FILE); |
@@ -9097,7 +9098,7 @@ minus_o(char *name, int val) | |||
9097 | return; | 9098 | return; |
9098 | } | 9099 | } |
9099 | } | 9100 | } |
9100 | ash_msg_and_raise_error("Illegal option -o %s", name); | 9101 | ash_msg_and_raise_error("illegal option -o %s", name); |
9101 | } | 9102 | } |
9102 | out1str("Current option settings\n"); | 9103 | out1str("Current option settings\n"); |
9103 | for (i = 0; i < NOPTS; i++) | 9104 | for (i = 0; i < NOPTS; i++) |
@@ -9115,7 +9116,7 @@ setoption(int flag, int val) | |||
9115 | return; | 9116 | return; |
9116 | } | 9117 | } |
9117 | } | 9118 | } |
9118 | ash_msg_and_raise_error("Illegal option -%c", flag); | 9119 | ash_msg_and_raise_error("illegal option -%c", flag); |
9119 | /* NOTREACHED */ | 9120 | /* NOTREACHED */ |
9120 | } | 9121 | } |
9121 | static void | 9122 | static void |
@@ -9368,7 +9369,7 @@ getoptscmd(int argc, char **argv) | |||
9368 | char **optbase; | 9369 | char **optbase; |
9369 | 9370 | ||
9370 | if (argc < 3) | 9371 | if (argc < 3) |
9371 | ash_msg_and_raise_error("Usage: getopts optstring var [arg]"); | 9372 | ash_msg_and_raise_error("usage: getopts optstring var [arg]"); |
9372 | if (argc == 3) { | 9373 | if (argc == 3) { |
9373 | optbase = shellparam.p; | 9374 | optbase = shellparam.p; |
9374 | if (shellparam.optind > shellparam.nparam + 1) { | 9375 | if (shellparam.optind > shellparam.nparam + 1) { |
@@ -9405,7 +9406,7 @@ static void raise_error_syntax(const char *) ATTRIBUTE_NORETURN; | |||
9405 | static void | 9406 | static void |
9406 | raise_error_syntax(const char *msg) | 9407 | raise_error_syntax(const char *msg) |
9407 | { | 9408 | { |
9408 | ash_msg_and_raise_error("Syntax error: %s", msg); | 9409 | ash_msg_and_raise_error("syntax error: %s", msg); |
9409 | /* NOTREACHED */ | 9410 | /* NOTREACHED */ |
9410 | } | 9411 | } |
9411 | 9412 | ||
@@ -11803,7 +11804,7 @@ umaskcmd(int argc, char **argv) | |||
11803 | } else { | 11804 | } else { |
11804 | mask = ~mask & 0777; | 11805 | mask = ~mask & 0777; |
11805 | if (!bb_parse_mode(ap, &mask)) { | 11806 | if (!bb_parse_mode(ap, &mask)) { |
11806 | ash_msg_and_raise_error("Illegal mode: %s", ap); | 11807 | ash_msg_and_raise_error("illegal mode: %s", ap); |
11807 | } | 11808 | } |
11808 | umask(~mask & 0777); | 11809 | umask(~mask & 0777); |
11809 | } | 11810 | } |