Re: Problem with function cd in bash 4.0
Chet Ramey wrote: > > Interesting. This happens only on Linux. FreeBSD, MacOS X, and Solaris > all interrupt and return to $PS1. > > Chet > Actually, this was happening for me on Solaris too, so looks like not just a Linux thing. But your patch fixed the issue on Solaris as well. Richard -- View this message in context: http://www.nabble.com/Problem-with-function-cd-in-bash-4.0-tp22171999p0451.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: Problem with function cd in bash 4.0
On Wednesday 25 February 2009 16:21:47 Chet Ramey wrote: > > > Yep, it's a bug. Try the attached patch; it works for me. > > > > this introduces a bug of it's own though :/. you can no longer use > > ctrl+c to escape from unbalanced quotes. > > > > - type: echo ' > > - hit enter > > - hit ctrl+c over and over > > - bash still waits for the ' to be balanced > > Still not sure what extra stuff Linux runs to make this only fail there, > but here's a patch that should fix it. seems to fix the issue on my system, thanks -mike
Re: Problem with function cd in bash 4.0
> > Yep, it's a bug. Try the attached patch; it works for me. > > this introduces a bug of it's own though :/. you can no longer use ctrl+c to > escape from unbalanced quotes. > > - type: echo ' > - hit enter > - hit ctrl+c over and over > - bash still waits for the ' to be balanced Still not sure what extra stuff Linux runs to make this only fail there, but here's a patch that should fix it. Chet *** ../bash-4.0/parse.y 2009-01-08 08:29:12.0 -0500 --- parse.y 2009-02-25 15:58:25.0 -0500 *** *** 2669,2672 --- 2671,2675 word_desc_to_read = (WORD_DESC *)NULL; + current_token = '\n'; /* XXX */ last_read_token = '\n'; token_to_read = '\n'; ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://tiswww.tis.case.edu/~chet/
Re: Problem with function cd in bash 4.0
Mike Frysinger wrote: > this introduces a bug of it's own though :/. you can no longer use ctrl+c to > escape from unbalanced quotes. > > - type: echo ' > - hit enter > - hit ctrl+c over and over > - bash still waits for the ' to be balanced Interesting. This happens only on Linux. FreeBSD, MacOS X, and Solaris all interrupt and return to $PS1. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: Problem with function cd in bash 4.0
On Monday 23 February 2009 23:02:56 Chet Ramey wrote: > Bernd Eggink wrote: > > I normally wrap the builtin cd into a function cd, which does some > > additional things and then calls the builtin. Example: > > > >function cd > >{ > > local list=$(echo *.bui) > > # ... > > builtin cd "$1" > >} > > > > I have a PS1 like this: > > > >PS1="\\w \$ " > > > > With bash 3, this worked well; cd-ing into a directory changed the > > prompt immediately. With bash 4, however, the prompt keeps unchanged > > after a call to cd and only gets adjusted after the _next_ command. I > > noticed that this depends on a subshell being used in the function. > > Without that, it behaves as before. > > > > Is that a bug? I can get the intended behaviour by putting > > > >eval "PS1='$PS1'" > > > > at the end of the function, but that's a rather ugly workaround. > > Yep, it's a bug. Try the attached patch; it works for me. this introduces a bug of it's own though :/. you can no longer use ctrl+c to escape from unbalanced quotes. - type: echo ' - hit enter - hit ctrl+c over and over - bash still waits for the ' to be balanced -mike
Re: Problem with function cd in bash 4.0
Chet Ramey wrote: > > I posted a patch for this earlier. Look at > > http://lists.gnu.org/archive/html/bug-bash/2009-02/msg00153.html > > and see if it fixes things for you. > > Chet > Ah yes, that was indeed the problem. Fixed for me as well now. Thanks. -- View this message in context: http://www.nabble.com/Problem-with-function-cd-in-bash-4.0-tp22171999p22191924.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: Problem with function cd in bash 4.0
Richard Leeden wrote: > Unfortunately doesn't work for me > > I'm doing something to Bernd - i.e. I have a function called cd that calls > the builtin cd after doing some extra things. In bash 4.0 with my cd > function enabled I get a bus error and the shell quits each time I attempt a > tab completion on cd. To make things easier I replaced my (rather > complicated) function with the very simple: That's a problem with completion, not anything to do with whether you have a function named `cd' defined. I posted a patch for this earlier. Look at http://lists.gnu.org/archive/html/bug-bash/2009-02/msg00153.html and see if it fixes things for you. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: Problem with function cd in bash 4.0
monoped wrote: > > Works for me, too. Thanks! > Unfortunately doesn't work for me I'm doing something to Bernd - i.e. I have a function called cd that calls the builtin cd after doing some extra things. In bash 4.0 with my cd function enabled I get a bus error and the shell quits each time I attempt a tab completion on cd. To make things easier I replaced my (rather complicated) function with the very simple: function cd { builtin cd "$1" } I've applied the patch and recompiled but still get the same bus error. Some info about my build though: Machine: sparc OS: solaris2.9 Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' -DCONF_OSTYPE='solaris2.9' -DCONF_MACHTYPE='sparc-sun-solaris2.9' -DCONF_VENDOR='sun' -DLOCALEDIR='/usr/local/share/l ocale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DSOLARIS -I. -I. -I./include -I./lib -I/usr/local/include -g -O2 uname output: SunOS flapjack 5.9 Generic_122300-21 sun4u sparc SUNW,UltraSPARC-IIi-cEngine Machine Type: sparc-sun-solaris2.9 Bash Version: 4.0 Patch Level: 0 Release Status: release And some gdb output (after typing cd ): root|flapjack>cd Program received signal SIGSEGV, Segmentation fault. restore_token_state (ts=0xe8a41) at parse.y:1632 1632 last_read_token = ts[0]; (gdb) backtrace #0 restore_token_state (ts=0xe8a41) at parse.y:1632 #1 0x0002a560 in restore_parser_state (ps=0xffbfe070) at parse.y:5562 #2 0x00072e60 in gen_compspec_completions (cs=0x1f5888, cmd=0x20e688 "cd ", word=0xf0018 "", start=0, end=3) at pcomplete.c:1043 #3 0x0007372c in programmable_completions (cmd=0x1c9cd8 "cd", word=0xf0018 "", start=0, end=3, foundp=0xffbfe18c) at pcomplete.c:1444 #4 0x0006b560 in attempt_shell_completion (text=0xf0018 "", start=3, end=3) at bashline.c:1334 #5 0x0009bfb4 in gen_completion_matches (text=0xf0018 "", start=3, end=3, our_func=0x9c644 , found_quote=0, quote_char=0) at complete.c:1023 #6 0x0009c084 in rl_complete_internal (what_to_do=33) at complete.c:1746 #7 0x00094e5c in _rl_dispatch_subseq (key=9, map=0xe3550, got_subseq=0) at readline.c:769 #8 0x00095244 in readline_internal_char () at readline.c:548 #9 0x00095864 in readline (prompt=0xe7c00 "") at readline.c:575 #10 0x0002818c in yy_readline_get () at parse.y:1314 #11 0x00028128 in yy_getc () at parse.y:1247 #12 0x0002ac8c in shell_getc (remove_quoted_newline=1) at parse.y:2096 #13 0x0002d294 in read_token (command=0) at parse.y:2729 #14 0x00030a00 in yyparse () at parse.y:2362 #15 0x00027b08 in parse_command () at eval.c:228 #16 0x00027bd0 in read_command () at eval.c:272 #17 0x00027d60 in reader_loop () at eval.c:137 #18 0x00027010 in main (argc=1, argv=0xffbff2e4, env=0xffbff2ec) at shell.c:741 (gdb) Thanks, Richard -- View this message in context: http://www.nabble.com/Problem-with-function-cd-in-bash-4.0-tp22171999p22186602.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: Problem with function cd in bash 4.0
Chet Ramey schrieb: Bernd Eggink wrote: I normally wrap the builtin cd into a function cd, which does some additional things and then calls the builtin. Example: function cd { local list=$(echo *.bui) # ... builtin cd "$1" } I have a PS1 like this: PS1="\\w \$ " With bash 3, this worked well; cd-ing into a directory changed the prompt immediately. With bash 4, however, the prompt keeps unchanged after a call to cd and only gets adjusted after the _next_ command. I noticed that this depends on a subshell being used in the function. Without that, it behaves as before. Is that a bug? I can get the intended behaviour by putting eval "PS1='$PS1'" at the end of the function, but that's a rather ugly workaround. Yep, it's a bug. Try the attached patch; it works for me. Works for me, too. Thanks! Bernd -- Bernd Eggink http://sudrala.de
Re: Problem with function cd in bash 4.0
Bernd Eggink wrote: > I normally wrap the builtin cd into a function cd, which does some > additional things and then calls the builtin. Example: > >function cd >{ > local list=$(echo *.bui) > # ... > builtin cd "$1" >} > > I have a PS1 like this: > >PS1="\\w \$ " > > With bash 3, this worked well; cd-ing into a directory changed the > prompt immediately. With bash 4, however, the prompt keeps unchanged > after a call to cd and only gets adjusted after the _next_ command. I > noticed that this depends on a subshell being used in the function. > Without that, it behaves as before. > > Is that a bug? I can get the intended behaviour by putting > >eval "PS1='$PS1'" > > at the end of the function, but that's a rather ugly workaround. Yep, it's a bug. Try the attached patch; it works for me. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/ *** ../bash-4.0/parse.y 2009-01-08 08:29:12.0 -0500 --- parse.y 2009-02-23 22:40:55.0 -0500 *** *** 1616,1623 int *ret; ! ret = (int *)xmalloc (3 * sizeof (int)); ret[0] = last_read_token; ret[1] = token_before_that; ret[2] = two_tokens_ago; return ret; } --- 1616,1624 int *ret; ! ret = (int *)xmalloc (4 * sizeof (int)); ret[0] = last_read_token; ret[1] = token_before_that; ret[2] = two_tokens_ago; + ret[3] = current_token; return ret; } *** *** 1632,1635 --- 1633,1637 token_before_that = ts[1]; two_tokens_ago = ts[2]; + current_token = ts[3]; }
Problem with function cd in bash 4.0
I normally wrap the builtin cd into a function cd, which does some additional things and then calls the builtin. Example: function cd { local list=$(echo *.bui) # ... builtin cd "$1" } I have a PS1 like this: PS1="\\w \$ " With bash 3, this worked well; cd-ing into a directory changed the prompt immediately. With bash 4, however, the prompt keeps unchanged after a call to cd and only gets adjusted after the _next_ command. I noticed that this depends on a subshell being used in the function. Without that, it behaves as before. Is that a bug? I can get the intended behaviour by putting eval "PS1='$PS1'" at the end of the function, but that's a rather ugly workaround. Regards, Bernd -- Bernd Eggink http://sudrala.de