ch, ch, !!(dest->o_expflags & EXP_FLAG_ESC_GLOB_CHARS));
if (process_bkslash && ch == '\\') {
if (next == EOF) {
+// TODO: what if in interactive shell a file with
+// echo "unterminated string\<eof>
+// is sourced?
syntax_error("\\<eof>");
xfunc_die();
}
next = '\0';
if (ch != '\n') {
- next = i_peek(input);
- /* Can't use i_peek_and_eat_bkslash_nl(input) here:
+ /* Do not break this case:
* echo '\
* '
- * will break.
+ * and
+ * echo z\\
*/
+ next = (ch == '\'' || ch == '\\') ? i_peek(input) : i_peek_and_eat_bkslash_nl(input);
+///
}
is_special = "{}<>;&|()#'" /* special outside of "str" */
goto parse_error;
}
redir_style = REDIRECT_OVERWRITE;
- if (next == '\\')
- next = i_peek_and_eat_bkslash_nl(input);
if (next == '>') {
redir_style = REDIRECT_APPEND;
ch = i_getch(input);
goto parse_error;
}
redir_style = REDIRECT_INPUT;
- if (next == '\\')
- next = i_peek_and_eat_bkslash_nl(input);
if (next == '<') {
redir_style = REDIRECT_HEREDOC;
heredoc_cnt++;
continue; /* back to top of while (1) */
}
break;
+#if 0 /* looks like we never reach this code */
case '\\':
if (next == '\n') {
/* It's "\<newline>" */
continue; /* back to top of while (1) */
}
break;
+#endif
}
if (ctx.is_assignment == MAYBE_ASSIGNMENT
break;
case '\\':
if (next == EOF) {
+//TODO: in ". FILE" containing "cmd\" (no newline) bash ignores last "\"
syntax_error("\\<eof>");
xfunc_die();
}
if (done_word(&ctx)) {
goto parse_error;
}
- if (next == '\\')
- next = i_peek_and_eat_bkslash_nl(input);
if (next == '&') {
ch = i_getch(input);
nommu_addchr(&ctx.as_string, ch);
if (ctx.ctx_res_w == RES_MATCH)
break; /* we are in case's "word | word)" */
#endif
- if (next == '\\')
- next = i_peek_and_eat_bkslash_nl(input);
if (next == '|') { /* || */
ch = i_getch(input);
nommu_addchr(&ctx.as_string, ch);