aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-07-03 14:30:59 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-07-03 14:30:59 +0200
commite5692e2342c68092ee3d4d895ea847cf7d13fa57 (patch)
treeca165ac601de2c2f7e77058ab1541b250a2dd9b5
parentcc9543fed1f916f62a63cfbe9eaefba3df8e22cb (diff)
downloadbusybox-w32-e5692e2342c68092ee3d4d895ea847cf7d13fa57.tar.gz
busybox-w32-e5692e2342c68092ee3d4d895ea847cf7d13fa57.tar.bz2
busybox-w32-e5692e2342c68092ee3d4d895ea847cf7d13fa57.zip
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.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 426182924..ec4f3a2f2 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -11307,8 +11307,8 @@ static int FAST_FUNC builtin_export(char **argv)
11307 11307
11308 if (!p) /* wtf? take next variable */ 11308 if (!p) /* wtf? take next variable */
11309 continue; 11309 continue;
11310 /* export var= */ 11310 /* "export VAR=" */
11311 printf("export %.*s", (int)(p - s) + 1, s); 11311 printf("%s %.*s", "export", (int)(p - s) + 1, s);
11312 print_escaped(p + 1); 11312 print_escaped(p + 1);
11313 putchar('\n'); 11313 putchar('\n');
11314# endif 11314# endif
@@ -11352,8 +11352,15 @@ static int FAST_FUNC builtin_readonly(char **argv)
11352 struct variable *e; 11352 struct variable *e;
11353 for (e = G.top_var; e; e = e->next) { 11353 for (e = G.top_var; e; e = e->next) {
11354 if (e->flg_read_only) { 11354 if (e->flg_read_only) {
11355//TODO: quote value: readonly VAR='VAL' 11355 const char *s = e->varstr;
11356 printf("readonly %s\n", e->varstr); 11356 const char *p = strchr(s, '=');
11357
11358 if (!p) /* wtf? take next variable */
11359 continue;
11360 /* "readonly VAR=" */
11361 printf("%s %.*s", "readonly", (int)(p - s) + 1, s);
11362 print_escaped(p + 1);
11363 putchar('\n');
11357 } 11364 }
11358 } 11365 }
11359 return EXIT_SUCCESS; 11366 return EXIT_SUCCESS;