From b6251bff913972b5dfb421813fe97a5bfff3627f Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 18 Nov 2018 04:56:48 +0100 Subject: 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. --- sys/src/cmd/rc/exec.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'sys/src/cmd/rc/exec.c') 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* -- cgit v1.2.3