This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/RFC] Problem with '!' escaping with zsh/bash/ksh


Hello,

the following change introduced a problem when forking inferiors when
the path to the executable contains '!' characters. This only occurs
with sh-like shells, like zsh/bash/ksh. I have reproduced this on Linux
and HP/UX.

        * fork-inferior.c (fork_inferior): Add '!' to the list of
        characters that need to be quoted when building a string for the
        shell.  Quote '!' specifically with a backslash, since CSH chokes
        when trying to evaluate "str!str". 

Witness:

        (gdb) run
        Starting program: /home/brobecke/tmp/GEO_ENV!9.159/foo 
        zsh: no such file or directory: /home/brobecke/tmp/GEO_ENV\!9.159/foo
        
        Program exited with code 01.
        You can't do that without a process to debug.

As far as I can tell from the comments in fork_inferior and my own
experiments, the bang should be escaped only for C shells. To reflect
this, I have made the following change to fork-child.c.

2002-05-02  J. Brobecker  <brobecker@gnat.com>

        * fork-child.c (escape_bang_in_quoted_argument): New function.
        (fork_inferior): Escape '!' characters in quoted arguments
        only when needed.

Tested on HP/UX, with SHELL set to ZSH. No regression. Also tested by
verifying that it does fix the problem without breaking csh. Ok to apply?
Some better suggestions, maybe?

Thanks,
-- 
Joel

Attachment: fork-child.c.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]