On Thu, Oct 25, 2012 at 10:47 PM, Glenn Fowler <[email protected]> wrote:
> > 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" > More examples with ksh: === 1 === $ a=ro b=ot c= $ echo ~$a$b$c /root >From the result we can see the tilde expansion is done after $a, $b and $c are all expanded. (~$a$b$c ==> ~root ==> /root) === 2 === $ a=ro b=ot c=/ $ echo ~$a$b$c ~root/ So why no tilde expansion here? (~$a$b$c ==> ~root/ ==> /root/ ?) > > > "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] > > > >
_______________________________________________ ast-users mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-users
