Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ~ substitution



2011/1/8 sergio <mailbox@xxxxxxxxxxxxx>

> Hello.
>
> Is it possible, to control ~ substitution?
> When I type 'echo ~' I get '/home/sergio' --- all right.
> When I type 'echo a~b' I get 'a~b' --- all right.
> Also sh and bash do the same.
>
> But when I type 'echo h=~' (or h=~sergio, or h=~/some/path) I get 'h=~'.
> sh does the same, and bash will out 'h=/home/sergio'.
>
> How to control this? Why this may be bad? May be this is a bug?
>

Hi,

Try 'setopt magicequalsubst'.


man zshexpn:
[â]
FILENAME EXPANSION
    Each  word is checked to see if it begins with an unquoted `~'.
[â]
  Notes
    Filename  expansion is performed on the right hand side of a parameter
    assignment, including those appearing after commands  of  the  typeset
    family.
[â]
    If the option MAGIC_EQUAL_SUBST is set, any unquoted shell argument in
    the  form  `identifier=expression' becomes eligible for file expansion
    as described in the previous paragraph.  Quoting the  first  `='  also
    inhibits this.
[â]


Guillaume


Messages sorted by: Reverse Date, Date, Thread, Author