diff options
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c index 8b8d5fc8b..bccd9c1e9 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -8965,6 +8965,7 @@ static int FAST_FUNC builtin_umask(char **argv) | |||
8965 | int rc; | 8965 | int rc; |
8966 | mode_t mask; | 8966 | mode_t mask; |
8967 | 8967 | ||
8968 | rc = 1; | ||
8968 | mask = umask(0); | 8969 | mask = umask(0); |
8969 | argv = skip_dash_dash(argv); | 8970 | argv = skip_dash_dash(argv); |
8970 | if (argv[0]) { | 8971 | if (argv[0]) { |
@@ -8974,19 +8975,19 @@ static int FAST_FUNC builtin_umask(char **argv) | |||
8974 | /* symbolic umasks are inverted: "umask a=rx" calls umask(222) */ | 8975 | /* symbolic umasks are inverted: "umask a=rx" calls umask(222) */ |
8975 | if (!isdigit(argv[0][0])) | 8976 | if (!isdigit(argv[0][0])) |
8976 | mask ^= 0777; | 8977 | mask ^= 0777; |
8977 | rc = bb_parse_mode(argv[0], &mask); | 8978 | mask = bb_parse_mode(argv[0], mask); |
8978 | if (!isdigit(argv[0][0])) | 8979 | if (!isdigit(argv[0][0])) |
8979 | mask ^= 0777; | 8980 | mask ^= 0777; |
8980 | if (rc == 0 || (unsigned)mask > 0777) { | 8981 | if ((unsigned)mask > 0777) { |
8981 | mask = old_mask; | 8982 | mask = old_mask; |
8982 | /* bash messages: | 8983 | /* bash messages: |
8983 | * bash: umask: 'q': invalid symbolic mode operator | 8984 | * bash: umask: 'q': invalid symbolic mode operator |
8984 | * bash: umask: 999: octal number out of range | 8985 | * bash: umask: 999: octal number out of range |
8985 | */ | 8986 | */ |
8986 | bb_error_msg("%s: invalid mode '%s'", "umask", argv[0]); | 8987 | bb_error_msg("%s: invalid mode '%s'", "umask", argv[0]); |
8988 | rc = 0; | ||
8987 | } | 8989 | } |
8988 | } else { | 8990 | } else { |
8989 | rc = 1; | ||
8990 | /* Mimic bash */ | 8991 | /* Mimic bash */ |
8991 | printf("%04o\n", (unsigned) mask); | 8992 | printf("%04o\n", (unsigned) mask); |
8992 | /* fall through and restore mask which we set to 0 */ | 8993 | /* fall through and restore mask which we set to 0 */ |