From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 512 invoked by alias); 3 May 2003 16:59:29 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 499 invoked from network); 3 May 2003 16:59:28 -0000 Received: from unknown (HELO crack.them.org) (146.82.138.56) by sources.redhat.com with SMTP; 3 May 2003 16:59:28 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 19C0MP-0005Xv-00; Sat, 03 May 2003 11:59:41 -0500 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 19C0M0-0004G4-00; Sat, 03 May 2003 12:59:16 -0400 Date: Sat, 03 May 2003 16:59:00 -0000 From: Daniel Jacobowitz To: Joel Brobecker Cc: Eli Zaretskii , gdb-patches@sources.redhat.com Subject: Re: [RFA/RFC] Problem with '!' escaping with zsh/bash/ksh Message-ID: <20030503165915.GA16323@nevyn.them.org> Mail-Followup-To: Joel Brobecker , Eli Zaretskii , gdb-patches@sources.redhat.com References: <20030502233458.GP992@gnat.com> <1438-Sat03May2003113601+0300-eliz@elta.co.il> <20030503143251.GA1878@nevyn.them.org> <20030503165109.GT992@gnat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20030503165109.GT992@gnat.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2003-05/txt/msg00029.txt.bz2 On Sat, May 03, 2003 at 09:51:09AM -0700, Joel Brobecker wrote: > Daniel said: > > By the time it gets to execve, we have: > > execve("/home/drow/foo/foo\\!bar/ls", ["/home/drow/foo/foo\\!bar/ls"], > > > > i.e. the backslash has been escaped too! > > Unfortunately, this is not what's happening: > > (top-gdb) p shell_command > $1 = 0xbffff2f0 "exec '/home/brobecke/tmp/GEO_ENV\\!9.159/foo' " > > The value printed for shell_command is misleading (the double backslash), > when you dump the memory at the address string, I only see one backslash: > > (top-gdb) x /50c 0xbffff2f0 > 0xbffff2f0: 101 'e' 120 'x' 101 'e' 99 'c' 32 ' ' 39 '\'' 47 '/' 104 'h' > 0xbffff2f8: 111 'o' 109 'm' 101 'e' 47 '/' 98 'b' 114 'r' 111 'o' 98 'b' > 0xbffff300: 101 'e' 99 'c' 107 'k' 101 'e' 47 '/' 116 't' 109 'm' 112 'p' > 0xbffff308: 47 '/' 71 'G' 69 'E' 79 'O' 95 '_' 69 'E' 78 'N' 86 'V' > 0xbffff310: 92 '\\' 33 '!' 57 '9' 46 '.' 49 '1' 53 '5' 57 '9' 47 '/' > ^^^^^^^ > 0xbffff318: 102 'f' 111 'o' 111 'o' 39 '\'' 32 ' ' 0 '\0' -1 'ÿ' -65 '¿' > 0xbffff320: 102 'f' -48 'Ð' Ah, OK. strace apparently does the same thing. Shame on me. > Eli said: > > Are you saying that zsh doesn't support escaping of arbitrary > > characters with a backslash? That is, under zsh, "\a" is not the same > > as "a"? I'd be surprised. > > If I restrict myself to using a zsh shell alone, outside of GDB, here is > the behavior I get: > > With the backlash: > % zsh > % exec '/home/brobecke/tmp/GEO_ENV\!9.159/foo' > zsh: no such file or directory: /home/brobecke/tmp/GEO_ENV\!9.159/foo > % > > Without the backslash > % zsh > % exec '/home/brobecke/tmp/GEO_ENV!9.159/foo' > % > > I think you are right to say that "\a" is equivalent to "a" in general. > However, in our case, the argument is quoted, specifically single-quoted. > And it seems to make a big difference: with single quotes, the > expression is no longer evaluated. That's why the backslash becomes > harmful. > > Daniel said: > > By the way... what would the general reaction be to supporting exec'ing > > the program directly instead of through the shell? At least as an > > option, since it would be a bit of an interface/quoting change? > > I think that'd be very nice, actually. Can somebody tell me what the > advantage of forking via a shell is? Globbing, primarily; and it handles some complexities of quoting (but introduces others!). Me, I think on modern systems we can just do argument splitting and globbing ourselves if we want to. It's more efficient and less fragile. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer