bug-bash
[Top][All Lists]
Advanced

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

Re: autocd doesn't invoke customized `cd` wrapper


From: Piotr Grzybowski
Subject: Re: autocd doesn't invoke customized `cd` wrapper
Date: Sun, 3 Jan 2016 01:44:37 +0100

hi,

 I am not sure if autocd is supposed and expected to run just anything
called "cd", but for what its worth, the following patch does what you
want.

diff --git a/execute_cmd.c b/execute_cmd.c
index daa08c2..9a29da0 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -4297,6 +4297,11 @@ run_builtin:

   if (autocd && interactive && words->word && is_dirname (words->word->word))
     {
+      if ((func = find_function("cd")) != NULL)
+        {
+          words = make_word_list (make_word ("cd"), words);
+          goto run_builtin;
+        }
       words = make_word_list (make_word ("--"), words);
       words = make_word_list (make_word ("cd"), words);
       xtrace_print_word_list (words, 0);


cheers,
pg




On Fri, Jan 1, 2016 at 10:41 PM,  <address@hidden> wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
> -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -D_FORTIFY_SOURCE=2 
> -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat 
> -Werror=format-security -Wall
> uname output: Linux laptop 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 
> 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
>
> Bash Version: 4.3
> Patch Level: 11
> Release Status: release
>
> Description:
>   If `cd` is a function or an alias in my environment, I think autocd ought 
> to invoke
>   that instead of the raw `command cd` (like it does now).
>
>   Personally, I keep a stack of recent directories and I record frequences of 
> the directories I'm
>   in in my `cd` wrapper, and it'd be nice if autocd didn't circumvent the 
> wrapper.
>
> Repeat-By:
>
>   Steps to reproduce:
>     $ cd(){ echo cding; command cd "$@"; }
>     $ shopt -s autocd
>     $ /etc
>       cd /etc
>     # cd /var
>       cding
>
> Fix:
>         [Description of how to fix the problem.  If you don't know a
>         fix for the problem, don't include this section.]
>



reply via email to

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