[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange behaviour when sourcing files with functions
From: |
Chet Ramey |
Subject: |
Re: Strange behaviour when sourcing files with functions |
Date: |
Wed, 27 Aug 2003 15:17:26 -0400 |
> In this case, the sourced script doesn't manipulate the positional
> parameters - it doesn't use set or shift - so it does seem like a bug.
> OTOH, I can't reproduce it with bash 2.05b with the current patches,
> so it seems to have been fixed already. (BTW, wouldn't it make more
> sense to make the positional parameters persist only if they were
> manipulated *and* none were explicitly passed to the sourced script?
> Making them persist also when some were explicitly passed seems less
> useful, and wouldn't have affected backward compatibility.)
It was a compromise. Scripts run with `.' are supposed to behave as
if the commands were entered interactively or appeared inline in some
shell script. If a script run with `.' establishes a new set of
positional parameters with `set', it expects them to persist after `.'
completes. That is backwards compatibility.
There is also the issue of whether or not `.' was executed in a shell
function to complicate matters, since function calls explicitly save
and= restore the positional parameters.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live...Laugh...Love
Chet Ramey, ITS, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/