unbreak other cases where $@ shares double quotes with something else
This commit is contained in:
parent
1248a0a521
commit
be1a0e3282
23
eval.c
23
eval.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.163 2015/02/06 10:09:05 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.164 2015/02/19 22:01:13 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* string expansion
|
* string expansion
|
||||||
@ -59,10 +59,11 @@ typedef struct {
|
|||||||
#define XSUBMID 6 /* middle of expanding ${} */
|
#define XSUBMID 6 /* middle of expanding ${} */
|
||||||
|
|
||||||
/* States used for field splitting */
|
/* States used for field splitting */
|
||||||
#define IFS_WORD 0 /* word has chars (or quotes) */
|
#define IFS_WORD 0 /* word has chars (or quotes except "$@") */
|
||||||
#define IFS_WS 1 /* have seen IFS white-space */
|
#define IFS_WS 1 /* have seen IFS white-space */
|
||||||
#define IFS_NWS 2 /* have seen IFS non-white-space */
|
#define IFS_NWS 2 /* have seen IFS non-white-space */
|
||||||
#define IFS_IWS 3 /* begin of word, ignore IFS WS */
|
#define IFS_IWS 3 /* begin of word, ignore IFS WS */
|
||||||
|
#define IFS_QUOTE 4 /* beg.w/quote, become IFS_WORD unless "$@" */
|
||||||
|
|
||||||
static int varsub(Expand *, const char *, const char *, int *, int *);
|
static int varsub(Expand *, const char *, const char *, int *, int *);
|
||||||
static int comsub(Expand *, const char *, int);
|
static int comsub(Expand *, const char *, int);
|
||||||
@ -290,7 +291,7 @@ expand(
|
|||||||
c = *sp++;
|
c = *sp++;
|
||||||
break;
|
break;
|
||||||
case OQUOTE:
|
case OQUOTE:
|
||||||
word = IFS_WORD;
|
word = IFS_QUOTE;
|
||||||
tilde_ok = 0;
|
tilde_ok = 0;
|
||||||
quote = 1;
|
quote = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -383,6 +384,8 @@ expand(
|
|||||||
if (f & DOBLANK)
|
if (f & DOBLANK)
|
||||||
doblank++;
|
doblank++;
|
||||||
tilde_ok = 0;
|
tilde_ok = 0;
|
||||||
|
if (word == IFS_QUOTE && type != XNULLSUB)
|
||||||
|
word = IFS_WORD;
|
||||||
if (type == XBASE) {
|
if (type == XBASE) {
|
||||||
/* expand? */
|
/* expand? */
|
||||||
if (!st->next) {
|
if (!st->next) {
|
||||||
@ -709,8 +712,14 @@ expand(
|
|||||||
if (x.str[0] != '\0') {
|
if (x.str[0] != '\0') {
|
||||||
word = IFS_IWS;
|
word = IFS_IWS;
|
||||||
type = XSUB;
|
type = XSUB;
|
||||||
} else
|
} else if (quote) {
|
||||||
type = quote ? XSUB : XNULLSUB;
|
word = IFS_WORD;
|
||||||
|
type = XSUB;
|
||||||
|
} else {
|
||||||
|
if (dp == Xstring(ds, dp))
|
||||||
|
word = IFS_IWS;
|
||||||
|
type = XNULLSUB;
|
||||||
|
}
|
||||||
if (f & DOBLANK)
|
if (f & DOBLANK)
|
||||||
doblank++;
|
doblank++;
|
||||||
st = st->prev;
|
st = st->prev;
|
||||||
@ -803,7 +812,7 @@ expand(
|
|||||||
type = XBASE;
|
type = XBASE;
|
||||||
if (f & DOBLANK) {
|
if (f & DOBLANK) {
|
||||||
doblank--;
|
doblank--;
|
||||||
if (dp == Xstring(ds, dp))
|
if (dp == Xstring(ds, dp) && word != IFS_WORD)
|
||||||
word = IFS_IWS;
|
word = IFS_IWS;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -915,7 +924,7 @@ expand(
|
|||||||
* IFS_IWS -/WS w/NWS -
|
* IFS_IWS -/WS w/NWS -
|
||||||
* (w means generate a word)
|
* (w means generate a word)
|
||||||
*/
|
*/
|
||||||
if ((word == IFS_WORD) || (c &&
|
if ((word == IFS_WORD) || (word == IFS_QUOTE) || (c &&
|
||||||
(word == IFS_IWS || word == IFS_NWS) &&
|
(word == IFS_IWS || word == IFS_NWS) &&
|
||||||
!ctype(c, C_IFSWS))) {
|
!ctype(c, C_IFSWS))) {
|
||||||
emit_word:
|
emit_word:
|
||||||
|
Loading…
Reference in New Issue
Block a user