Thanks all. I also went the quote route, but made it more complicated than needs to be. I'm now using Anthony's version.
On Tue, May 19, 2026 at 11:57 PM Anthony Martin <[email protected]> wrote: > > Skip Tavakkolian <[email protected]> once said: > > I don't believe there is a good way of preserving quotes (') in $*. I > > ran into this while trying to: > > > > % window winwatch -e '^(winwatch|stats|faces)' # will not work > > % window winwatch -e '''^(winwatch|stats|faces)''' # works > > > > I think this comes down to how quotes are handled in $*: > > > > % tail -1 /rc/bin/window # the relevant line > > if not echo new -cd `{pwd} $* >> `{getwctl} > > > > having to stack quotes manually makes interactions like cut-paste > > awkward/unusable. > > The problem is programs being lazy about what they give to rc(1). > > For example, writing > > new [opitions] cmd args ... > > to the wctl file of rio(4) will execute > > rc -c 'cmd args ...' > > and this will fail if the string passed to -c is not properly quoted. > > I wrote a small tool to help with this a long time ago and modified > various programs like window(1) to use it. It's called rcquote. > > % cat `{src -n rcquote | sed 's,:[0-9]+$,,'} > #include <u.h> > #include <libc.h> > > void > main(int argc, char *argv[]) > { > int i; > > argv++,argc--; > if(argc == 0) > exits(nil); > doquote = needsrcquote; > quotefmtinstall(); > for(i = 0; i < argc; i++) > print("%q%c", argv[i], i == argc-1 ? '\n' : ' '); > exits(nil); > } > > % echo winwatch -e '^(winwatch|stats|faces)' > winwatch -e ^(winwatch|stats|faces) > > % rcquote winwatch -e '^(winwatch|stats|faces)' > winwatch -e '^(winwatch|stats|faces)' > > Cheers, > Anthony ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Te16808448e498abd-Mae147d90fbc5604cdb1bd153 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
