Dean K. Gibson wrote:
> If bash script A is invoked (via "source") with command line parameters, 
> and bash script A invokes (via "source") bash script B with NO 
> parameters specified, then the parameters specified for A are passed to 
> B (rather than what I would have thought would be the expected 
> behaviour, that script B is called with NO parameters).
> 
> Is this intended behaviour, or a bug?  I've worked around it by 
> specifying in script A just one null ("") parameter to script B.

Yes that is expected behavior.  If you source a script without
parameters then it is as if that script were included in the parent.
It is as if the script is run in exactly the same environment.  On the
other hand if you pass parameters then the script is called with the
$* positional parameter set to those arguments.

This matches the existing legacy practice of /bin/sh on systems for
many years.  If you want to clear the parameter list then using set --
is the typical way to do this.

  set --

Bob



_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to