rio: allow spaces in working directory path (-cd) when creating a new window via wctl
The initial working directory of a new window may be set by a `-cd directory` option. However, the `-cd directory` option is not capable of handling paths with spaces when used via wctl. To enable paths with spaces the function /sys/src/cmd/rio/wctl.c:/^parsewctl is extended to handle quoted directory paths. Before applying the patch the following will fail to open a new window by writing to /dev/wctl: <snip> % rio -i window % mkdir '/tmp/path with space' % echo new -cd '''/tmp/path with space''' window -x rc >> /dev/wctl % pwd /tmp/path with space <snap> The following invocation fails as well: <snip> % window -cd '/tmp/path with space' % pwd /tmp/path with space <snap> After applying the patch the above sequences work as expected, opening a window running rc with the working directory set to '/tmp/path with space'.
This commit is contained in:
parent
5d69d42ee3
commit
614f1d6268
2 changed files with 9 additions and 6 deletions
|
@ -100,6 +100,6 @@ if not {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! ~ $#wdir 0)
|
if(! ~ $#wdir 0)
|
||||||
spec=($spec -cd $wdir)
|
spec=($spec -cd `{a=$wdir whatis a|sed 's!^a=!!;q'})
|
||||||
echo new $spec $argv0 -x $cmd >>$wctl
|
echo new $spec $argv0 -x $cmd >>$wctl
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ int
|
||||||
parsewctl(char **argp, Rectangle r, Rectangle *rp, int *pidp, int *idp, int *hiddenp, int *scrollingp, char **cdp, char *s, char *err)
|
parsewctl(char **argp, Rectangle r, Rectangle *rp, int *pidp, int *idp, int *hiddenp, int *scrollingp, char **cdp, char *s, char *err)
|
||||||
{
|
{
|
||||||
int cmd, param, xy, sign;
|
int cmd, param, xy, sign;
|
||||||
char *t;
|
char *f[2], *t;
|
||||||
|
|
||||||
*pidp = 0;
|
*pidp = 0;
|
||||||
*hiddenp = 0;
|
*hiddenp = 0;
|
||||||
|
@ -252,10 +252,13 @@ parsewctl(char **argp, Rectangle r, Rectangle *rp, int *pidp, int *idp, int *hid
|
||||||
s++;
|
s++;
|
||||||
if(param == Cd){
|
if(param == Cd){
|
||||||
*cdp = s;
|
*cdp = s;
|
||||||
while(*s && !isspace(*s))
|
gettokens(*cdp, f, nelem(f), " \t\r\n\v\f");
|
||||||
s++;
|
s += strlen(*cdp);
|
||||||
if(*s != '\0')
|
if((*cdp)[0] == '\'' && s[-1] == '\''){
|
||||||
*s++ = '\0';
|
/* drop quotes */
|
||||||
|
*cdp += 1;
|
||||||
|
s[-1] = '\0';
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sign = 0;
|
sign = 0;
|
||||||
|
|
Loading…
Reference in a new issue