> The real problem is that when rio(1) reads what window(1) writes to
> the wctl file this gets passed to an invocation of `rc -c ...` which
> means you end up going through eval again.

Actually, that's not true; you need to quote the arguments before
writing to the wctl file.  Probably you want to do something like:

        echo new -cd `{pwd} `{quote $*} >> `{getwctl}

Where quote is a program I wrote that uses the %q format verb to quote
each argument.  Like so:

#include <u.h>
#include <libc.h>
#include <bio.h>

static void
usage(void)
{
        fprint(2, "usage: %s [args...]\n", argv0);
        exits("usage");
}

void
main(int argc, char **argv)
{
        int i;
        Biobuf *stdin, *stdout;
        char *line;

        ARGBEGIN{
        default:
                usage();
        }ARGEND;
        quotefmtinstall();
        stdout = Bfdopen(1, OWRITE);
        if(argc == 0){
                stdin = Bfdopen(0, OREAD);
                while(line = Brdstr(stdin, '\n', 1)){
                        Bprint(stdout, "%q\n", line);
                        free(line);
                }
        }else{
                for(i = 0; i < argc; i++){
                        if(i > 0)
                                Bputc(stdout, ' ');
                        Bprint(stdout, "%q", argv[i]);
                }
                Bputc(stdout, '\n');
        }
}

You're still going to have problems if the current working directory
ever contains spaces though!

--
Cheers,
Alex Musolino


------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Te16808448e498abd-M3d38d5f147c1d687d5f533b1
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to