diff options
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c index e8aef2d7e..4e29f01a1 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -3174,6 +3174,7 @@ static char *fetch_till_str(o_string *as_string, | |||
3174 | ch = i_getch(input); | 3174 | ch = i_getch(input); |
3175 | nommu_addchr(as_string, ch); | 3175 | nommu_addchr(as_string, ch); |
3176 | if (ch == '\n' | 3176 | if (ch == '\n' |
3177 | /* TODO: or EOF? (heredoc delimiter may end with <eof>, not only <eol> */ | ||
3177 | && ((heredoc_flags & HEREDOC_QUOTED) || prev != '\\') | 3178 | && ((heredoc_flags & HEREDOC_QUOTED) || prev != '\\') |
3178 | ) { | 3179 | ) { |
3179 | if (strcmp(heredoc.data + past_EOL, word) == 0) { | 3180 | if (strcmp(heredoc.data + past_EOL, word) == 0) { |
@@ -3182,7 +3183,8 @@ static char *fetch_till_str(o_string *as_string, | |||
3182 | return heredoc.data; | 3183 | return heredoc.data; |
3183 | } | 3184 | } |
3184 | do { | 3185 | do { |
3185 | o_addchr(&heredoc, ch); | 3186 | o_addchr(&heredoc, '\n'); |
3187 | prev = 0; /* not \ */ | ||
3186 | past_EOL = heredoc.length; | 3188 | past_EOL = heredoc.length; |
3187 | jump_in: | 3189 | jump_in: |
3188 | do { | 3190 | do { |
@@ -3196,8 +3198,12 @@ static char *fetch_till_str(o_string *as_string, | |||
3196 | return NULL; | 3198 | return NULL; |
3197 | } | 3199 | } |
3198 | o_addchr(&heredoc, ch); | 3200 | o_addchr(&heredoc, ch); |
3201 | if (prev == '\\' && ch == '\\') | ||
3202 | /* Correctly handle foo\\<eol> (not a line cont.) */ | ||
3203 | prev = 0; /* not \ */ | ||
3204 | else | ||
3205 | prev = ch; | ||
3199 | nommu_addchr(as_string, ch); | 3206 | nommu_addchr(as_string, ch); |
3200 | prev = ch; | ||
3201 | } | 3207 | } |
3202 | } | 3208 | } |
3203 | 3209 | ||