On 1/21/14 12:30 PM, Lionel Cons wrote:
> On 21 January 2014 01:16, Elliott Forney <elliott.for...@gmail.com> wrote:
>> I find it a little unpleasant that cd echoes the new working directory
>> when CDPATH is used to locate the new directory (I already have the
>> working directory in my prompt).  I understand that this is behavior
>> is mandated by POSIX but I wonder if we could have an option that
>> disables this.
>>
>> Maybe if the `cd' builtin had an option, say `-q', that would cause it
>> to be quit if CDPATH is used.  Then, I could simply
>>
>> alias cd='cd -q'
>>
>> and put a stop to this.  I have attached a proposed patch, any thoughts?
> 
> Yes, adding yet another option which can be implemented using POSIX
> behaviour is IMHO code bloat. Just use alias cd='2>"/dev/null" cd '
> (yes, POSIX mandates that re-directions can be prefixed and not only
> postfixed).

This is true, except that the redirection needs to be for stdout, not
stderr.  We can also use a shell function, since bash allows functions
to override builtins:

cd()
{
        builtin cd "$@" >/dev/null
}


The question boils down, as it always does, to whether or not it's most
valuable to embed this functionality in the shell itself rather than
require users to do `something'.  The answer is different for different
features.  I have not decided on the right answer in this case; I am
concentrating my efforts on getting bash-4.3 released.

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

Reply via email to