diff options
author | Denys Vlasenko | 2023-07-03 14:30:59 +0200 |
---|---|---|
committer | Denys Vlasenko | 2023-07-03 14:30:59 +0200 |
commit | e5692e2342c68092ee3d4d895ea847cf7d13fa57 (patch) | |
tree | ca165ac601de2c2f7e77058ab1541b250a2dd9b5 | |
parent | cc9543fed1f916f62a63cfbe9eaefba3df8e22cb (diff) | |
download | busybox-e5692e2342c68092ee3d4d895ea847cf7d13fa57.zip busybox-e5692e2342c68092ee3d4d895ea847cf7d13fa57.tar.gz |
hush: quote values in "readonly" output
function old new delta
builtin_readonly 61 107 +46
builtin_export 140 145 +5
.rodata 105321 105304 -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 51/-17) Total: 34 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/shell/hush.c b/shell/hush.c index 4261829..ec4f3a2 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -11307,8 +11307,8 @@ static int FAST_FUNC builtin_export(char **argv) if (!p) /* wtf? take next variable */ continue; - /* export var= */ - printf("export %.*s", (int)(p - s) + 1, s); + /* "export VAR=" */ + printf("%s %.*s", "export", (int)(p - s) + 1, s); print_escaped(p + 1); putchar('\n'); # endif @@ -11352,8 +11352,15 @@ static int FAST_FUNC builtin_readonly(char **argv) struct variable *e; for (e = G.top_var; e; e = e->next) { if (e->flg_read_only) { -//TODO: quote value: readonly VAR='VAL' - printf("readonly %s\n", e->varstr); + const char *s = e->varstr; + const char *p = strchr(s, '='); + + if (!p) /* wtf? take next variable */ + continue; + /* "readonly VAR=" */ + printf("%s %.*s", "readonly", (int)(p - s) + 1, s); + print_escaped(p + 1); + putchar('\n'); } } return EXIT_SUCCESS; |