← Commit list

e5692e234

Denys Vlasenko
Denys Vlasenko
2023-07-03
SUCCESS Duration: 153s

Subject

hush: quote values in "readonly" output

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/hush.c+11 -4
@@ -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;