diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2016-04-27 12:46:24 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2016-04-27 12:46:24 +0000 |
commit | 59b6448154166af6015531166a0bc46b7e574f47 (patch) | |
tree | 4fd12c7e03126b8678c4fd352fb39a1a2cb74364 /bin | |
parent | 03ca33f6ae36bacdbdee8d4be7b7f30c4b1d920b (diff) |
Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.
ok millert@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ksh/ksh.1 | 31 | ||||
-rw-r--r-- | bin/ksh/lex.c | 44 |
2 files changed, 15 insertions, 60 deletions
diff --git a/bin/ksh/ksh.1 b/bin/ksh/ksh.1 index d460db9acd1..557b4a0eb0b 100644 --- a/bin/ksh/ksh.1 +++ b/bin/ksh/ksh.1 @@ -1,8 +1,8 @@ -.\" $OpenBSD: ksh.1,v 1.178 2016/03/21 13:35:00 tb Exp $ +.\" $OpenBSD: ksh.1,v 1.179 2016/04/27 12:46:23 naddy Exp $ .\" .\" Public Domain .\" -.Dd $Mdocdate: March 21 2016 $ +.Dd $Mdocdate: April 27 2016 $ .Dt KSH 1 .Os .Sh NAME @@ -822,12 +822,6 @@ the and the newline are stripped; otherwise, both the .Ql \e and the character following are unchanged. -.Pp -.Sy Note : -See -.Sx POSIX mode -below for a special rule regarding -differences in quoting when the shell is in POSIX mode. .Ss Aliases There are two types of aliases: normal command aliases and tracked aliases. Command aliases are normally used as a short hand for a long or often used @@ -2473,27 +2467,6 @@ The following is a list of things that are affected by the state of the option: .Bl -bullet .It -Occurrences of -.Ic \e\&" -inside double quoted -.Ic `..` -command substitutions. -In POSIX mode, the -.Ic \e\&" -is interpreted when the command is interpreted; -in non-POSIX mode, -the backslash is stripped before the command substitution is interpreted. -For example, -.Ic echo \&"`echo \e\&"hi\e\&"`\&" -produces -.Dq \&"hi\&" -in POSIX mode, -.Dq hi -in non-POSIX mode. -To avoid problems, use the -.Ic $(...)\& -form of command substitution. -.It .Ic kill -l output. In POSIX mode, only signal names are listed (in a single line); diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c index 73c54b3af37..c33a0b93354 100644 --- a/bin/ksh/lex.c +++ b/bin/ksh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.68 2016/03/04 09:37:23 czarkoff Exp $ */ +/* $OpenBSD: lex.c,v 1.69 2016/04/27 12:46:23 naddy Exp $ */ /* * lexical analysis and source input @@ -427,40 +427,22 @@ yylex(int cf) /* Need to know if we are inside double quotes * since sh/at&t-ksh translate the \" to " in * "`..\"..`". - * This is not done in posix mode (section - * 3.2.3, Double Quotes: "The backquote shall - * retain its special meaning introducing the - * other form of command substitution (see - * 3.6.3). The portion of the quoted string - * from the initial backquote and the - * characters up to the next backquote that - * is not preceded by a backslash (having - * escape characters removed) defines that - * command whose output replaces `...` when - * the word is expanded." - * Section 3.6.3, Command Substitution: - * "Within the backquoted style of command - * substitution, backslash shall retain its - * literal meaning, except when followed by - * $ ` \."). */ statep->ls_sbquote.indquotes = 0; - if (!Flag(FPOSIX)) { - Lex_state *s = statep; - Lex_state *base = state_info.base; - while (1) { - for (; s != base; s--) { - if (s->ls_state == SDQUOTE) { - statep->ls_sbquote.indquotes = 1; - break; - } - } - if (s != base) - break; - if (!(s = s->ls_info.base)) + Lex_state *s = statep; + Lex_state *base = state_info.base; + while (1) { + for (; s != base; s--) { + if (s->ls_state == SDQUOTE) { + statep->ls_sbquote.indquotes = 1; break; - base = s-- - STATE_BSIZE; + } } + if (s != base) + break; + if (!(s = s->ls_info.base)) + break; + base = s-- - STATE_BSIZE; } break; default: |