aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-07 17:55:33 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-07 17:55:33 +0200
commit5711a2a4ad51ad203a2ed4ffc72593e83920b36a (patch)
treeef650852b982768fa9c3e4065016e09cbf2d0a96 /shell/hush.c
parentc1e2e005b4e99070f58a3545bad54ef41a634ad1 (diff)
downloadbusybox-5711a2a4ad51ad203a2ed4ffc72593e83920b36a.tar.gz
libbb: more compact API for bb_parse_mode()
function old new delta make_device 2182 2188 +6 parse_command 1440 1443 +3 parse_params 1497 1499 +2 install_main 773 769 -4 mkdir_main 168 160 -8 getoptscmd 641 632 -9 builtin_umask 158 147 -11 bb_parse_mode 431 410 -21 umaskcmd 286 258 -28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/6 up/down: 11/-81) Total: -70 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c7
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)
int rc;
mode_t mask;
+ rc = 1;
mask = umask(0);
argv = skip_dash_dash(argv);
if (argv[0]) {
@@ -8974,19 +8975,19 @@ static int FAST_FUNC builtin_umask(char **argv)
/* symbolic umasks are inverted: "umask a=rx" calls umask(222) */
if (!isdigit(argv[0][0]))
mask ^= 0777;
- rc = bb_parse_mode(argv[0], &mask);
+ mask = bb_parse_mode(argv[0], mask);
if (!isdigit(argv[0][0]))
mask ^= 0777;
- if (rc == 0 || (unsigned)mask > 0777) {
+ if ((unsigned)mask > 0777) {
mask = old_mask;
/* bash messages:
* bash: umask: 'q': invalid symbolic mode operator
* bash: umask: 999: octal number out of range
*/
bb_error_msg("%s: invalid mode '%s'", "umask", argv[0]);
+ rc = 0;
}
} else {
- rc = 1;
/* Mimic bash */
printf("%04o\n", (unsigned) mask);
/* fall through and restore mask which we set to 0 */