Closed euclaise closed 1 year ago
Your example works for me. This implementation certainly exports its functions into the environment. Something else is going on?
Oh, interesting.
After further testing (repeating it in bash and itself), it seems to occur specifically when rc is ran from the yash
shell.
That’s really weird. If you can narrow it down further I’d be grateful for details on this issue.
I'll try when I have some more time
Another note:
Both plan9port and this rc respond with rc: .: can't open: No such file or directory
when running the file without the ./
, but only plan9port's does in bash and dash.
Other interesting behavior:
bash rc
returns /usr/bin/rc: /usr/bin/rc: cannot execute binary file
, dash and yash return similar. However, bash (and not the others) can run bash 9 rc
.
yash -c "rc a.rc"
returns the expected
Things get even more confusing...
Same shell, two different terminal windows:
It seems I'm plagued with inconsistent issues today. I had a globbing issue earlier on a different computer that caused an unintended rm -rf /*
, but I can't seem to reproduce it on my laptop.
I can't explain what is going on but I wonder if you are running one shell with another shell's functions in its environment. Plan9port and my rc have undoubtedly different serializations of shell functions in the environment.
A side note: when you invoke bash rc
you are instructing bash to run the rc binary as a shell script. That can't and shouldn't work.
I can't explain what is going on but I wonder if you are running one shell with another shell's functions in its environment. Plan9port and my rc have undoubtedly different serializations of shell functions in the environment.
Unless I accidentally added another level of nesting, both of those should have been running from a single yash
instance under the default environment from xfce4-terminal
A side note: when you invoke bash rc you are instructing bash to run the rc binary as a shell script. That can't and shouldn't work.
Oh, duh, I feel silly now :b... 9
is a shell script, makes sense
Actually, that means 9's rc is running from an instance of yash nested within the first instance of yash, since it's a /bin/sh script
Oh, it indeed seems it to be an incompatibility between rcs. The original script ran this rc on the second script even when it was run from 9 rc
, since rc
links to this rc.
euclaise@thinkpad ~ 1 $ cat a.rc
fn myfn {
echo hello
}
rc ./b.rc
euclaise@thinkpad ~ $ cat a.9rc
fn myfn {
echo hello
}
/usr/lib/plan9/bin/rc ./b.rc
euclaise@thinkpad ~ $ cat b.rc
myfn
euclaise@thinkpad ~ $ rc ./a.rc
hello
euclaise@thinkpad ~ $ 9 rc ./a.rc
hello
euclaise@thinkpad ~ $ /usr/lib/plan9/bin/rc ./a.rc
rc: cannot find `myfn'
euclaise@thinkpad ~ 1 $ 9 rc ./a.9rc
hello
euclaise@thinkpad ~ $ /usr/lib/plan9/bin/rc ./a.9rc
hello
euclaise@thinkpad ~ $
Makes sense, I'll reopen if it seems to be something else (which may very well happen, considering the previous inconsistency), but I'll assume that's all it is for now. It's unfortunate that function serialization isn't standardized.
I noticed that this version of rc doesn't export functions like the Plan 9 (and p9p) version does.
Example
a.rc:
b.rc:
Result (vs plan9port for comparison)
9front's rc yields the same result as plan9port's