bug-bash
[Top][All Lists]
Advanced

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

Re: Strange behaviour when sourcing files with functions


From: Paul Jarc
Subject: Re: Strange behaviour when sourcing files with functions
Date: Tue, 26 Aug 2003 11:37:24 -0400
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Chet Ramey <chet@nike.ins.cwru.edu> wrote:
>> Bash Version: 2.05a
>>
>> $ echo '. foo ooh ; echo $1' > fooscript
>> $ echo : > foo
>> $ bash fooscript aah
>> aah
>> $ echo 'fnc() { :; } ; fnc' > foo
>> $ bash fooscript aah
>> ooh
...
> However, for backwards compatibility, if the commands in the script executed
> with `.' manipulate the positional parameters, they persist once the script
> completes.

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


paul




reply via email to

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