[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with "$@" variable
From: |
Chet Ramey |
Subject: |
Re: Problem with "$@" variable |
Date: |
Sat, 14 Mar 2009 17:47:24 -0400 |
User-agent: |
Thunderbird 2.0.0.19 (Macintosh/20081209) |
w8sdz@mail.petersen.net wrote:
> cd()
> {
> builtin cd "$0" && xtitle $HOST: $PWD
> }
>
> This no longer works correctly since I upgraded bash to the version
> listed above. Instead, when I use cd without an argument the following
> error message:
>
> -bash: $@: unbound variable
>
> Repeat-By:
> Add the above function to your .profile. When you cd
> with an argument as in cd /var/tmp it works as expected. When
> you wish to return to your home directory do a cd with no argument.
> The error appears every time.
Run without `set -u' enabled. Bash-4.0 was changed to include $@ and $*
in the variables subject to `set -u'. Those expansions will exit the
shell when there are no positional parameters.
(There is a problem with this: ${@:-foo} also exits the shell with an
unbound variable error. I'm working on a fix for that.)
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/