summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorslioch <slioch@eng-140.vyatta.com>2008-08-28 10:21:45 -0700
committerslioch <slioch@eng-140.vyatta.com>2008-08-28 10:21:45 -0700
commit8885d068b5830240895645ca6432f53eacb51d71 (patch)
treec108f0996f2e4d431c37d258a644229909141d48
parentdc6a7a5657b06a8058f559adb6b486dfcaf483ec (diff)
downloadvyatta-bash-8885d068b5830240895645ca6432f53eacb51d71.tar.gz
vyatta-bash-8885d068b5830240895645ca6432f53eacb51d71.zip
Handle double and single quote within a command argument. First quote turns on automatic escaping, second turns off. Will support unquoted, single quoted and
double quoted forms of text strings.
-rw-r--r--parse.y42
1 files changed, 21 insertions, 21 deletions
diff --git a/parse.y b/parse.y
index e9323c8..68e9537 100644
--- a/parse.y
+++ b/parse.y
@@ -1984,18 +1984,27 @@ shell_getc (remove_quoted_newline)
//find where string starts (skipping whitespace)
if (strncmp(&shell_input_line[pos],"set ",4) == 0 ||
- strncmp(&shell_input_line[pos],"delete",4) == 0) {
- if ((c == ';' ||
- c == '&' ||
- c == '(' ||
- c == ')' ||
- c == '>' ||
- c == '<' ||
- c == '|' ||
- c == '!' ||
- c == '`' ||
- c == '$') &&
- shell_input_line[i-1] != '\\') {
+ strncmp(&shell_input_line[pos],"delete ",7) == 0) {
+ if (c == '"' || c == '\'') {
+ //this suppresses a quoted string
+ if (no_escape == 1) {
+ no_escape = 0;
+ }
+ else {
+ no_escape = 1;
+ }
+ }
+ else if ((c == ';' ||
+ c == '&' ||
+ c == '(' ||
+ c == ')' ||
+ c == '>' ||
+ c == '<' ||
+ c == '|' ||
+ c == '!' ||
+ c == '`' ||
+ c == '$') &&
+ shell_input_line[i-1] != '\\') {
if (no_escape == 0) {
shell_input_line[i++] = '\\';
@@ -2008,15 +2017,6 @@ shell_getc (remove_quoted_newline)
}
}
}
- else if (c == '"') {
- //this suppresses a quoted string
- if (no_escape == 1) {
- no_escape = 0;
- }
- else {
- no_escape = 1;
- }
- }
}
shell_input_line[i++] = c;