bug-bash
[Top][All Lists]
Advanced

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

Re: bash silently ignores additional arguments for cd


From: Chet Ramey
Subject: Re: bash silently ignores additional arguments for cd
Date: Wed, 07 Dec 2011 16:29:11 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 12/7/11 8:21 AM, hanzl@noel.feld.cvut.cz wrote:

> Bash Version: 4.2
> Patch Level: 0
> Release Status: release
> 
> Description:
>       cd silently ignores additional arguments
>       pwd, pushd and popd also do ignore additional arguments
> 
>       This seemes to be a long standing behavior, it is the same in bash 
> 3.1.17.
> 
>       Problem is also described here: 
> http://old.nabble.com/cd-with-multiple-arguments--td30418151.html
> 
>       This bug is mostly benign, however missing newline at the end of a cd 
> command leads to
>       silent skip of the following command line. Error report would help here.

It's an interesting question.  There's a question about whether or not this
behavior, which is more-or-less traditional, is a bug at all.  While the
Bourne shells from v7 through SVR4.2 don't complain about multiple
arguments, many other Posix-style shells do.

My feeling on the matter is that this kind of behavior should be possible,
but it's not necessary to have it be the default.  It seems like it's a
relatively minor error case, and it's this kind of thing that motivated
the ability to have shell functions override shell builtins in the first
place.

For instance, the function replacement for cd that appears in
examples/kshenv in the bash distribution does what you want and more.

I agree with the suggestion in the referenced message thread about the
usefulness of a library of bash functions.  That was the original intent
of the examples/ subdirectory, but I hsven't solicited any contributions
for that in some time.  (Consider this a solicitation, if you're so
inclined.)

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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