[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BASH bug or expected behaviour?

From: Bob Proulx
Subject: Re: BASH bug or expected behaviour?
Date: Thu, 18 Aug 2005 01:34:03 -0600
User-agent: Mutt/1.5.9i

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 --


reply via email to

[Prev in Thread] Current Thread [Next in Thread]