← Commit list

bcf56114f

Denys Vlasenko
Denys Vlasenko
2018-04-10
SUCCESS Duration: 146s

Subject

hush: fix eval 'echo ok\'

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+9 -5
@@ -5379,15 +5379,19 @@ static struct pipe *parse_stream(char **pstring,
continue; /* get next char */
case '\\':
/*nommu_addchr(&ctx.as_string, '\\'); - already done */
- o_addchr(&ctx.word, '\\');
ch = i_getch(input);
if (ch == EOF) {
-//TODO: in ". FILE" containing "cmd\" (no newline) bash ignores last "\"
- syntax_error("\\<eof>");
- xfunc_die();
+ /* Ignore this '\'. Testcase: eval 'echo Ok\' */
+#if !BB_MMU
+ /* Remove trailing '\' from ctx.as_string */
+ ctx.as_string.data[--ctx.as_string.length] = '\0';
+#endif
+ continue; /* get next char */
}
+ o_addchr(&ctx.word, '\\');
/* Example: echo Hello \2>file
- * we need to know that word 2 is quoted */
+ * we need to know that word 2 is quoted
+ */
ctx.word.has_quoted_part = 1;
nommu_addchr(&ctx.as_string, ch);
o_addchr(&ctx.word, ch);
shell/hush_test/hush-parsing/bkslash_eof1.right+1 -0
@@ -0,0 +1 @@
+ok
shell/hush_test/hush-parsing/bkslash_eof1.tests+1 -0
@@ -0,0 +1 @@
+eval 'echo ok\'