[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: flag for quiet CDPATH
From: |
Chet Ramey |
Subject: |
Re: flag for quiet CDPATH |
Date: |
Tue, 21 Jan 2014 14:52:37 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 |
On 1/21/14 12:30 PM, Lionel Cons wrote:
> On 21 January 2014 01:16, Elliott Forney <elliott.forney@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 chet@case.edu http://cnswww.cns.cwru.edu/~chet/