On 25/10/2012 17:06, Clark WANG wrote:
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/ ?)
Each expansion method is done from start to end, without backtracking.
What we see is that parameter expansion is done first. Any following parameter
expansion is appended before attempting the tilde expansion.
If we expect `a=ro b=ot && echo ~$a$b` to result in /root, that implies that we
expect to concatenate any parameter expansion before giving it to tilde. Adding `c=/`
to the string will cause the tilde expansion to look for user 'root/', not user 'root'.
We might want tilde expansion to look for delimiters like `/`, to make it do
the intuitive thing.
Henk
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users