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 <[email protected]> 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
>
>

Reply via email to