On Thu, 25 Oct 2012 22:03:35 +0800 Clark WANG wrote:
> On Thu, Oct 25, 2012 at 9:43 PM, David Korn <[email protected]> wrote:
> > > I think bash behavior is correct according to
> > >
> > http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_
> > > 06which
> > > says tilde expansion should be done before parameter expansion.

> I see "The order of word expansion shall be as follows". I may
> misunderstand the context as English is not my first language. :)

"The order" refers to the order of the numbered list 1 2 3 4
the key phrase for 1. is "beginning to end" which means "altogether"

> > "Tilde expansion (see Tilde Expansion), parameter expansion (see Parameter
> > Expansion), command substitution (see Command Substitution), and arithmetic
> > expansion (see Arithmetic Expansion) shall be performed, beginning to end.
> > See item 5 in Token Recognition.
> >
> > which implies that these should be simultaneously from beginning to end.

> This make sense but ksh's behavior indicates that it makes two-pass parsing
> for ~$u, rather than one-pass from beginning to end. For a one-pass
> parsing, when it sees the ~ char and peeks at the next $ char it'll tell
> that tilde expansion is not possible; then it'll move forward and get the $
> char and peeks at the next u char and it will know that parameter expansion
> is needed.

> >
> > David Korn
> > [email protected]
> >

> --14dae93408b9b53bc204cce2add7
> Content-Type: text/html; charset=UTF-8
> Content-Transfer-Encoding: quoted-printable

> <font><font face=3D"arial,helvetica,sans-serif"></font></font>On Thu, Oct 2=
> 5, 2012 at 9:43 PM, David Korn <span dir=3D"ltr">&lt;<a href=3D"mailto:dgk@=
> research.att.com" target=3D"_blank">[email protected]</a>&gt;</span> wro=
> te:<br>

> <div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi=
> n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">cc: <a href=3D"ma=
> ilto:[email protected]">[email protected]</a><br>
> Subject: Re: [ast-users] =C2=A0[ksh93] Should ~$user be tilde expanded?<br>
> --------<br>
> <div class=3D"im"><br>
> <br>
> &gt; I think bash behavior is correct according to<br>
> &gt; <a href=3D"http://pubs.opengroup.org/onlinepubs/009695399/utilities/xc=
> u_chap02.html#tag_02_" target=3D"_blank">http://pubs.opengroup.org/onlinepu=
> bs/009695399/utilities/xcu_chap02.html#tag_02_</a><br>
> &gt; 06which<br>
> &gt; says tilde expansion should be done before parameter expansion.<br>
> &gt;<br>
> <br>
> </div>Where do you see that? =C2=A0In section 2.6, it says<br></blockquote>=
> <div><br>I see &quot;The order of word expansion shall be as follows&quot;.=
>  I may misunderstand the context as English is not my first language. :)<br=
> >

> <br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord=
> er-left:1px #ccc solid;padding-left:1ex">
> <br>
> &quot;Tilde expansion (see Tilde Expansion), parameter expansion (see Param=
> eter<br>
> Expansion), command substitution (see Command Substitution), and arithmetic=
> <br>
> expansion (see Arithmetic Expansion) shall be performed, beginning to end.<=
> br>
> See item 5 in Token Recognition.<br>
> <br>
> which implies that these should be simultaneously from beginning to end.<br=
> ></blockquote><div><br>This make sense but ksh&#39;s behavior indicates tha=
> t it makes two-pass parsing for ~$u, rather than one-pass from beginning to=
>  end. For a one-pass parsing, when it sees the ~ char and peeks at the next=
>  $ char it&#39;ll tell that tilde expansion is not possible; then it&#39;ll=
>  move forward and get the $ char and peeks at the next u char and it will k=
> now that parameter expansion is needed.<br>

> </div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
> eft:1px #ccc solid;padding-left:1ex">
> <span class=3D"HOEnZb"><font color=3D"#888888"><br>
> David Korn<br>
> <a href=3D"mailto:[email protected]";>[email protected]</a><br>
> </font></span></blockquote></div><br>

> --14dae93408b9b53bc204cce2add7--

> --===============3356089777672575947==
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline

> _______________________________________________
> ast-users mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-users

> --===============3356089777672575947==--

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to