commit 24ce628661cca1450bc2a57993c122a6266dc50a
parent 60da4cbe2337722dc0e86ce5cb4ab598e2243d60
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Fri, 29 Apr 2022 02:26:27 +0000
rename Handler as richrc and launch it by default
Diffstat:
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/extra/mkfile b/extra/mkfile
@@ -14,7 +14,7 @@ BIN=$SYSLIB/bin/$objtype
</sys/src/cmd/mkmany
RC=\
- Handler\
+ richrc\
install:V: bindir $RC
diff --git a/extra/Handler b/extra/richrc
diff --git a/richterm.c b/richterm.c
@@ -30,6 +30,7 @@ Image *Iscrollbar, *Ilink, *Inormbg, *Iselbg, *Itext;
Keyboardctl *kctl;
Mousectl *mctl;
Rich rich;
+char *cmd = "/bin/richrc";
char *srvname;
int hostpid = -1;
Array *drawcache;
@@ -82,7 +83,7 @@ enum {
void
usage(void)
{
- fprint(2, "usage: %s [-D] [-s srvname] [cmd [args]]\n", argv0);
+ fprint(2, "usage: %s [-D] [-c command] [-s srvname] [args]\n", argv0);
exits("usage");
}
@@ -98,6 +99,9 @@ threadmain(int argc, char **argv)
case 'D':
chatty9p++;
break;
+ case 'c':
+ cmd = EARGF(usage());
+ break;
case 's':
srvname = EARGF(usage());
break;
@@ -459,7 +463,7 @@ void
runcmd(void *args)
{
char **argv = args;
- char *cmd, *syslib, *cputype;
+ char *_cmd, *syslib, *cputype;
rfork(RFNAMEG);
@@ -482,14 +486,16 @@ runcmd(void *args)
open("/dev/cons", OWRITE);
dup(1, 2);
- cmd = nil;
+ _cmd = strdup(cmd);
while (*argv != nil) {
- if (cmd == nil) cmd = strdup(*argv);
- else cmd = smprint("%s %q", cmd, *argv);
+ char *old = _cmd;
+ _cmd = smprint("%s %q", _cmd, *argv);
+ free(old);
argv++;
}
- procexecl(pidchan, "/bin/rc", "rcX", cmd == nil ? nil : "-c", cmd, nil);
+ procexecl(pidchan, "/bin/rc", "rcX", "-c", _cmd, nil);
+
sysfatal("%r");
}