acme: add $acmeshell to control execution shell

R=rsc
CC=plan9port.codebot
http://codereview.appspot.com/6614056
This commit is contained in:
Marius Eriksen 2012-10-21 16:52:08 -04:00 committed by Russ Cox
parent 9c61127928
commit 81c2c5e775
4 changed files with 18 additions and 2 deletions

View file

@ -533,6 +533,12 @@ and
set to the window's id number set to the window's id number
(see (see
.IR acme (4)). .IR acme (4)).
.PP
The environment variable
.B $acmeshell
determines which shell is used to execute such commands; the
.IR rc (1)
shell is used by default.
.SS "Mouse button 3 .SS "Mouse button 3
Pointing at text with button 3 instructs Pointing at text with button 3 instructs
.I acme .I acme

View file

@ -133,6 +133,9 @@ threadmain(int argc, char *argv[])
cputype = getenv("cputype"); cputype = getenv("cputype");
objtype = getenv("objtype"); objtype = getenv("objtype");
home = getenv("HOME"); home = getenv("HOME");
acmeshell = getenv("acmeshell");
if(acmeshell && *acmeshell == '\0')
acmeshell = nil;
p = getenv("tabstop"); p = getenv("tabstop");
if(p != nil){ if(p != nil){
maxtab = strtoul(p, nil, 0); maxtab = strtoul(p, nil, 0);

View file

@ -535,6 +535,7 @@ int fsyspid;
char *cputype; char *cputype;
char *objtype; char *objtype;
char *home; char *home;
char *acmeshell;
char *fontnames[2]; char *fontnames[2];
Image *tagcols[NCOL]; Image *tagcols[NCOL];
Image *textcols[NCOL]; Image *textcols[NCOL];

View file

@ -1358,6 +1358,7 @@ runproc(void *argvp)
char *rcarg[4]; char *rcarg[4];
void **argv; void **argv;
CFsys *fs; CFsys *fs;
char *shell;
threadsetname("runproc"); threadsetname("runproc");
@ -1467,6 +1468,8 @@ runproc(void *argvp)
if(argaddr) if(argaddr)
putenv("acmeaddr", argaddr); putenv("acmeaddr", argaddr);
if(acmeshell != nil)
goto Hard;
if(strlen(t) > sizeof buf-10) /* may need to print into stack */ if(strlen(t) > sizeof buf-10) /* may need to print into stack */
goto Hard; goto Hard;
inarg = FALSE; inarg = FALSE;
@ -1576,7 +1579,10 @@ Hard:
chdir(dir); /* ignore error: probably app. window */ chdir(dir); /* ignore error: probably app. window */
free(dir); free(dir);
} }
rcarg[0] = "rc"; shell = acmeshell;
if(shell == nil)
shell = "rc";
rcarg[0] = shell;
rcarg[1] = "-c"; rcarg[1] = "-c";
rcarg[2] = t; rcarg[2] = t;
rcarg[3] = nil; rcarg[3] = nil;
@ -1590,7 +1596,7 @@ Hard:
sendul(cpid, ret); sendul(cpid, ret);
threadexits(nil); threadexits(nil);
} }
warning(nil, "exec rc: %r\n"); warning(nil, "exec %s: %r\n", shell);
Fail: Fail:
/* threadexec hasn't happened, so send a zero */ /* threadexec hasn't happened, so send a zero */