rminnich-macbookair:libc rminnich$ echo $objtype
amd64
rminnich-macbookair:libc rminnich$ echo $MKSHELL
/usr/local/plan9/bin/rc
rminnich-macbookair:libc rminnich$ mk
for(i in 9sys 9syscall fmt port thr $objtype)@{
echo $i
cd $i
mk $MKFLAGS install
}
sh: line 1: syntax error near unexpected token `('
mk: for(i in 9sys ... : exit status=exit(2)
Noce it did not pick up MKSHELL: it used rc. But it also is not
getting objtype (you can only see it failing with dtruss).
Is there some simple thing I'm missing here?
ron
In my sense, the MKSHELL is a definition of the mkfile,
not your environment.
It is defined in $PLAN9/src/cmd/mk/shell.c.
Why should the MKSHELL variable be imported from your
environment?
However, the other variables are correctly imported
into the mkfile, as expected.
% cat mkfile
<$PLAN9/src/mkhdr
all:
echo $objtype
% mk
echo $objtype
% objtype=386 mk
echo $objtype
386
--
David du Colombier
It is a variable. Why should it be different from any other mkfile
variable? I printed out the variables read in by code in env.c and
there is nothing special. It is inserted as any other variable.
>
> Why should the MKSHELL variable be imported from your
> environment?
Because it's a variable. Because I need mk to use rc and I'm on OSX. I
am not in a situation where I can change the mkfile in question as it
needs to work on Plan 9 and unix-like systems. So it has to come from
the environment.
Anyway, if someone else has looked at the code I'd be curious as to
what you think.
ron
Yes, but it is overwritten by setvar("MKSHELL", shellcmd)
in $PLAN9/src/cmd/mk/shell.c.
The value of shellcmd is set to sh by default, then it can
be modified every time "MKSHELL=" is parsed in the mkfile.
> Because it's a variable. Because I need mk to use rc and I'm on OSX. I
> am not in a situation where I can change the mkfile in question as it
> needs to work on Plan 9 and unix-like systems. So it has to come from
> the environment.
I think I understand your problem a little better.
The following patch should do what you want.
It will set the default shell to rc if you set the
environment variable MKSHELL to rc, and sh otherwise.
diff -r 8c55dad4023c src/cmd/mk/shell.c
--- a/src/cmd/mk/shell.c
+++ b/src/cmd/mk/shell.c
@@ -5,7 +5,7 @@
&shshell
};
-Shell *shelldefault = &shshell;
+Shell *shelldefault = nil;
Shell *shellt;
Word *shellcmd;
@@ -41,6 +41,16 @@
void
initshell(void)
{
+ char *sh;
+
+ if(shelldefault == nil){
+ sh = getenv("MKSHELL");
+ if(sh && strcmp(sh, "rc") == 0)
+ shelldefault = &rcshell;
+ else
+ shelldefault = &shshell;
+ }
+
shellcmd = stow(shelldefault->name);
shellt = shelldefault;
setvar("MKSHELL", shellcmd);
Does it answer your question?
--
David du Colombier
> Does it answer your question?
I'll try it later today, but I think your patch would be the right way to go.
ron
ron
put MKSHELL=rc at the top of your mkfile.
if you want a more plan 9-like mk, change
mk/shell.c's shelldefault to be &rcshell instead
of &shshell.
russ
> if you want a more plan 9-like mk, change
> mk/shell.c's shelldefault to be &rcshell instead
> of &shshell.
ok. that's what I had started to do anyway.
thanks
ron