diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-05-03 12:21:55 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-05-03 12:21:55 +0000 |
commit | 70e5b622fff4d3218106fb10f146200576b1f787 (patch) | |
tree | 76e8ee286e879f4e42e786717ab0fed2d5c1d2a6 /Src/subst.c | |
parent | 0d6350d65a856b74000393dd4c4f5453e8801444 (diff) | |
download | zsh-70e5b622fff4d3218106fb10f146200576b1f787.tar.gz zsh-70e5b622fff4d3218106fb10f146200576b1f787.tar.xz zsh-70e5b622fff4d3218106fb10f146200576b1f787.zip |
new (z) parameter flag to do shell-word splitting on the value (11113)
Diffstat (limited to 'Src/subst.c')
-rw-r--r-- | Src/subst.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Src/subst.c b/Src/subst.c index 668d5eda3..1f992dd54 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -750,6 +750,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) int casmod = 0; int quotemod = 0, quotetype = 0, quoteerr = 0; int visiblemod = 0; + int shsplit = 0; char *sep = NULL, *spsep = NULL; char *premul = NULL, *postmul = NULL, *preone = NULL, *postone = NULL; char *replstr = NULL; /* replacement string for /orig/repl */ @@ -971,6 +972,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) presc++; break; + case 'z': + shsplit = 1; + break; + default: flagerr: zerr("error in flags", NULL, 0); @@ -1748,6 +1753,34 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) val = nicedupstring(val); } } + if (shsplit) { + LinkList list = NULL; + + if (isarr) { + char **ap; + for (ap = aval; *ap; ap++) + list = bufferwords(list, *ap, NULL); + isarr = 0; + } else + list = bufferwords(NULL, val, NULL); + + if (!firstnode(list)) + val = dupstring(""); + else if (!nextnode(firstnode(list))) + val = getdata(firstnode(list)); + else { + char **ap; + LinkNode node; + + aval = ap = (char **) zhalloc((countlinknodes(list) + 1) * + sizeof(char *)); + for (node = firstnode(list); node; incnode(node)) + *ap++ = (char *) getdata(node); + *ap = NULL; + mult_isarr = isarr = 2; + } + copied = 1; + } if (isarr) { char *x; char *y; |