On Fri, 2002-11-22 at 14:56, Todd Lyons wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> ath1410 wrote on Fri, Nov 22, 2002 at 05:04:55PM +0900 :
> > 
> > I checked the sites you refered, but did not still quite figure
> > out (partly because of my poor English?) the way bash works the
> > way it does. To make things simple, just take up one case here.
> > $PS1=\\\\u           -4  returns \u
> > the 1st \ escapes the 2nd \, and the 3rd one to the 4th one
> > likewise.
> > So  $PS1=\\\\u is something like $PS1='\\u' ( which actually
> > returns \u, not user name.
> 
> Yes.
> 
> The following are identical:
> PS=\\\\u
> PS="\\\\u"
> 
> 
> This is NOT the same:
> PS='\\\\u'
> 
> Nor seemingly is this because of the single quoting which prevents
> parameter expansion.  I honestly thought it _would_ be the same, but if
> you say it doesn't work, then it doesn't work:
> PS='\\u'
> 
> The trick is that bash parses each commandline twice (repeating someone
> else's authoritative post from memory, so anybody more knowledgable,
> please feel free to correct errors).  The first time it converts "\\" to
> "\" and "\\" to "\", leaving you with "\\u".  The second time it
> converts "\\" to "\", leaving you with "\u".  That is what then gets
> used.

Actually no, it is parsed 3 times: once when you enter it not quoted in
the command line, a second time by the prompting decoding (only certain
specific backslah substitutions performed) and a third time if you
variable promptvars is set (set by default, see shopt). This explain the
small number of \ in the display prompt compared to what you used in the
command line.

Guillaume.


> Blue skies...                 Todd
> - -- 
>            MandrakeSoft USA   http://www.mandrakesoft.com
>           cat /boot/vmlinuz > /dev/dsp  #for great justice
>    Cooker Version mandrake-release-9.1-0.1mdk Kernel 2.4.20-0.2mdk
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> 
> iD8DBQE93ovilp7v05cW2woRAvyzAJ4sSqW6ez0W0GgYdIWGFMKs30zU1QCgrQxl
> ilYHcg/BLdcHjVTiGikMhaE=
> =LR3p
> -----END PGP SIGNATURE-----
> 
> ----
> 

> Want to buy your Pack or Services from MandrakeSoft? 
> Go to http://www.mandrakestore.com



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to