summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rc/exec.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-11-18 04:56:48 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2018-11-18 04:56:48 +0100
commitb6251bff913972b5dfb421813fe97a5bfff3627f (patch)
tree178e82fd271108762b93be4797d77df6d26abb72 /sys/src/cmd/rc/exec.c
parent196da4ec6f429683a351312d1f0bcb05847e7f89 (diff)
rc: implement $"x in terms of Xdol() and new Xqw() instruction
to get $"1 right, remove Xqdol() and instead implement it in terms of Xdol() instruction and use the new Xqw() instruction to quote the resulting list.
Diffstat (limited to 'sys/src/cmd/rc/exec.c')
-rw-r--r--sys/src/cmd/rc/exec.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/src/cmd/rc/exec.c b/sys/src/cmd/rc/exec.c
index 4400e45bc..3d1b0ac5a 100644
--- a/sys/src/cmd/rc/exec.c
+++ b/sys/src/cmd/rc/exec.c
@@ -233,7 +233,7 @@ main(int argc, char *argv[])
* Xdelfn(name) delete function definition
* Xdeltraps(names) delete named traps
* Xdol(name) get variable value
- * Xqdol(name) concatenate variable components
+ * Xqw(list) quote list, push result
* Xdup[i j] dup file descriptor
* Xexit rc exits with status
* Xfalse{...} execute {} if false
@@ -697,18 +697,22 @@ Xdol(void)
}
void
-Xqdol(void)
+Xqw(void)
{
char *s;
word *a;
- if(count(runq->argv->words)!=1){
- Xerror1("variable name not singleton!");
+
+ a = runq->argv->words;
+ if(a && a->next == 0){
+ runq->argv->words = 0;
+ poplist();
+ a->next = runq->argv->words;
+ runq->argv->words = a;
return;
}
- s = Str(runq->argv->words);
- a = vlook(s)->val;
+ s = list2str(a);
poplist();
- Pushword(list2str(a));
+ Pushword(s);
}
word*