From: Bruno Haible Date: Thu, 22 Jun 2006 11:27:01 +0000 (+0000) Subject: Recognize also <(...) and >(...) syntax. X-Git-Tag: v0.15~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=744d757f4a49984579344441fd9e1a41f5b21095;p=thirdparty%2Fgettext.git Recognize also <(...) and >(...) syntax. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 7e6b2a209..2df2f2682 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,7 @@ +2006-06-21 Bruno Haible + + * x-sh.c (read_word): Recognize the Bash process substitution syntax. + 2006-06-21 Bruno Haible * x-sh.c (read_word): Recognize $(...) and $((...)) also inside diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 8b18d40bc..d8ba7d635 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -759,21 +759,27 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) if (c == '<' || c == '>') { - /* Recognize the redirection operators < > >| << <<- >> <> <& >& */ + /* Recognize the redirection operators < > >| << <<- >> <> <& >& + But <( and >) are handled below, not here. */ int c2 = phase2_getc (); - if ((c == '<' ? c2 == '<' : c2 == '|') || c2 == '>' || c2 == '&') + if (c2 != '(') { - if (c == '<' && c2 == '<') + if ((c == '<' ? c2 == '<' : c2 == '|') || c2 == '>' || c2 == '&') { - int c3 = phase2_getc (); - if (c3 != '-') - phase2_ungetc (c3); + if (c == '<' && c2 == '<') + { + int c3 = phase2_getc (); + if (c3 != '-') + phase2_ungetc (c3); + } } + else + phase2_ungetc (c2); + wp->type = t_redirect; + return; } else phase2_ungetc (c2); - wp->type = t_redirect; - return; } if (looking_for == CLOSING_BACKQUOTE && c == CLOSING_BACKQUOTE) @@ -873,8 +879,8 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) c3 = phase2_getc (); if (c3 == '(') { - /* Arithmetic expression. Skip until the matching closing - parenthesis. */ + /* Arithmetic expression (Bash syntax). Skip until the + matching closing parenthesis. */ unsigned int depth = 2; do @@ -890,7 +896,7 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) } else { - /* Command substitution. */ + /* Command substitution (Bash syntax). */ phase2_ungetc (c3); read_command_list (')', context); } @@ -1127,6 +1133,27 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) if (c == CLOSING_BACKQUOTE) break; + if (c == '<' || c == '>') + { + int c2; + + /* An unquoted c indicates we are not inside '...' nor "...". */ + if (open_singlequote || open_doublequote) + abort (); + + c2 = phase2_getc (); + if (c2 == '(') + { + /* Process substitution (Bash syntax). */ + read_command_list (')', context); + + wp->type = t_other; + continue; + } + else + phase2_ungetc (c2); + } + if (!open_singlequote && !open_doublequote && (is_whitespace (c) || is_operator_start (c))) break;