Pretty clear, thanks! :-) So, to "fix" this rc would need an option to know to rfork(RFENVG) before doing anything else. Something like:
-f [nNeEsfFm] Start as a new process group using rfork(flags) This way lc would produce not surprises by simply adding "-f e" to the first line. It shouldn't be an hard fix, but I wonder if it's actually worth the effort. Also, probably -f is not the best flag here as it usually mean "file"... -r would be a better choice, but it's taken for debugging output. I might use -d for debugging output since -d is a no-op (why?) and -r for this early rfork, but I have no idea of what it would broke. Giacomo 2017-10-18 19:25 GMT+02:00 Skip Tavakkolian <skip.tavakkol...@gmail.com>: > yes. lc -- an rc script -- shares the environment with the rc that starts > it; so env is updated with arglist of lc. $* is the arglist that parent > (interactive) rc was started with. rc(1) says: > > $* Set to rc's argument list during initialization. > Whenever a . command or a function is executed, the > current value is saved and $* receives the new > argument list. The saved value is restored on com- > pletion of the . or function. > > if lc was a function, there would be no surprises: > > % cat /bin/lc > #!/bin/rc > ls -p $* | mc > % fn LC { ls -p $* | mc } > % echo $* > > % cat '/env/*' > % LC >/dev/null > % echo $* > > % cat '/env/*' > % > > On Wed, Oct 18, 2017 at 9:02 AM Antons Suspans <an...@ml.lv> wrote: >> >> On Wed, Oct 18, 2017 at 05:31:28PM +0200, Giacomo Tesio wrote: >> > I have been a bit surprised to see that $* does not always contains >> > the same as '/env/*': >> > >> > % echo $* >> > >> > % cat '/env/*' >> > % lc >> > bin/ lib/ tmp/ >> > % echo $* >> > >> > % cat '/env/*' >> > /bin/lc% >> > >> > Not really an issue, but why this happens? >> >> I guess... >> >> When starting a command from rc, execforkexec() does fork(), which >> is an equivalent of rfork(RFFDG|RFREND|RFPROC) and does not imply RFENVG. >> >> As lc(1) is a shell script, its shell instance sets /env/'*'. >> >> Hope this helps. >> >> -- >> Antons >> >