ash: remove parsebackquote flag
Commit 503a0b8 from git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu says: >The parsebackquote flag is only used in a test where it always has the >value zero. So we can remove it altogether. The first statement is incorrect: parsebackquote is non-zero when backquotes (as opposed to $(...)) are used for command substitution. It is possible for the test to be executed with parsebackquote != 0 in that case. The test is question checks whether quotes have been closed, raising the error "unterminated quoted string" if they haven't. There seems to be no good reason to allow unclosed quotes within backquotes. Bash, hush and dash (after commit 503a0b8) all treat the following as an error: XX=`"pwd` whereas BusyBox ash doesn't. It just ignores the unclosed quote and executes pwd. So, parsebackquote should be removed but not for the reason stated. function old new delta parsebackquote 1 - -1 readtoken1 3222 3182 -40 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-41) Total: -41 bytes Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
97f2f7ca7f
commit
0e056f7e9e
@ -10473,7 +10473,6 @@ struct heredoc {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static smallint tokpushback; /* last token pushed back */
|
static smallint tokpushback; /* last token pushed back */
|
||||||
static smallint parsebackquote; /* nonzero if we are inside backquotes */
|
|
||||||
static smallint quoteflag; /* set if (part of) last token was quoted */
|
static smallint quoteflag; /* set if (part of) last token was quoted */
|
||||||
static token_id_t lasttoken; /* last token read (integer id Txxx) */
|
static token_id_t lasttoken; /* last token read (integer id Txxx) */
|
||||||
static struct heredoc *heredoclist; /* list of here documents to read */
|
static struct heredoc *heredoclist; /* list of here documents to read */
|
||||||
@ -11313,7 +11312,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
|
|||||||
if (syntax == ARISYNTAX)
|
if (syntax == ARISYNTAX)
|
||||||
raise_error_syntax("missing '))'");
|
raise_error_syntax("missing '))'");
|
||||||
#endif
|
#endif
|
||||||
if (syntax != BASESYNTAX && !parsebackquote && eofmark == NULL)
|
if (syntax != BASESYNTAX && eofmark == NULL)
|
||||||
raise_error_syntax("unterminated quoted string");
|
raise_error_syntax("unterminated quoted string");
|
||||||
if (varnest != 0) {
|
if (varnest != 0) {
|
||||||
startlinno = g_parsefile->linno;
|
startlinno = g_parsefile->linno;
|
||||||
@ -11609,7 +11608,6 @@ parsesub: {
|
|||||||
*/
|
*/
|
||||||
parsebackq: {
|
parsebackq: {
|
||||||
struct nodelist **nlpp;
|
struct nodelist **nlpp;
|
||||||
smallint savepbq;
|
|
||||||
union node *n;
|
union node *n;
|
||||||
char *volatile str;
|
char *volatile str;
|
||||||
struct jmploc jmploc;
|
struct jmploc jmploc;
|
||||||
@ -11620,10 +11618,8 @@ parsebackq: {
|
|||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
(void) &saveprompt;
|
(void) &saveprompt;
|
||||||
#endif
|
#endif
|
||||||
savepbq = parsebackquote;
|
|
||||||
if (setjmp(jmploc.loc)) {
|
if (setjmp(jmploc.loc)) {
|
||||||
free(str);
|
free(str);
|
||||||
parsebackquote = 0;
|
|
||||||
exception_handler = savehandler;
|
exception_handler = savehandler;
|
||||||
longjmp(exception_handler->loc, 1);
|
longjmp(exception_handler->loc, 1);
|
||||||
}
|
}
|
||||||
@ -11707,7 +11703,6 @@ parsebackq: {
|
|||||||
nlpp = &(*nlpp)->next;
|
nlpp = &(*nlpp)->next;
|
||||||
*nlpp = stzalloc(sizeof(**nlpp));
|
*nlpp = stzalloc(sizeof(**nlpp));
|
||||||
/* (*nlpp)->next = NULL; - stzalloc did it */
|
/* (*nlpp)->next = NULL; - stzalloc did it */
|
||||||
parsebackquote = oldstyle;
|
|
||||||
|
|
||||||
if (oldstyle) {
|
if (oldstyle) {
|
||||||
saveprompt = doprompt;
|
saveprompt = doprompt;
|
||||||
@ -11741,7 +11736,6 @@ parsebackq: {
|
|||||||
str = NULL;
|
str = NULL;
|
||||||
INT_ON;
|
INT_ON;
|
||||||
}
|
}
|
||||||
parsebackquote = savepbq;
|
|
||||||
exception_handler = savehandler;
|
exception_handler = savehandler;
|
||||||
USTPUTC(CTLBACKQ, out);
|
USTPUTC(CTLBACKQ, out);
|
||||||
if (oldstyle)
|
if (oldstyle)
|
||||||
|
1
shell/ash_test/ash-misc/tickquote1.right
Normal file
1
shell/ash_test/ash-misc/tickquote1.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
./tickquote1.tests: line 1: syntax error: unterminated quoted string
|
1
shell/ash_test/ash-misc/tickquote1.tests
Executable file
1
shell/ash_test/ash-misc/tickquote1.tests
Executable file
@ -0,0 +1 @@
|
|||||||
|
echo `"pwd`
|
Loading…
Reference in New Issue
Block a user