* ~ substitution
@ 2011-01-08 9:42 sergio
2011-01-08 10:35 ` Guillaume Brunerie
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: sergio @ 2011-01-08 9:42 UTC (permalink / raw)
To: zsh-users
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?
--
sergio.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ~ substitution
2011-01-08 9:42 ~ substitution sergio
@ 2011-01-08 10:35 ` Guillaume Brunerie
2011-01-08 10:42 ` Mikael Magnusson
2011-01-08 10:44 ` Atom Smasher
2 siblings, 0 replies; 4+ messages in thread
From: Guillaume Brunerie @ 2011-01-08 10:35 UTC (permalink / raw)
To: sergio; +Cc: zsh-users
[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]
2011/1/8 sergio <mailbox@sergio.spb.ru>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ~ substitution
2011-01-08 9:42 ~ substitution sergio
2011-01-08 10:35 ` Guillaume Brunerie
@ 2011-01-08 10:42 ` Mikael Magnusson
2011-01-08 10:44 ` Atom Smasher
2 siblings, 0 replies; 4+ messages in thread
From: Mikael Magnusson @ 2011-01-08 10:42 UTC (permalink / raw)
To: sergio; +Cc: zsh-users
On 8 January 2011 10:42, sergio <mailbox@sergio.spb.ru> wrote:
> 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?
try setopt magicequalsubst
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ~ substitution
2011-01-08 9:42 ~ substitution sergio
2011-01-08 10:35 ` Guillaume Brunerie
2011-01-08 10:42 ` Mikael Magnusson
@ 2011-01-08 10:44 ` Atom Smasher
2 siblings, 0 replies; 4+ messages in thread
From: Atom Smasher @ 2011-01-08 10:44 UTC (permalink / raw)
To: sergio; +Cc: zsh-users
On Sat, 8 Jan 2011, sergio wrote:
> 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?
======================
echo foo=${:-~}
foo=/home/atom
--
...atom
________________________
http://atom.smasher.org/
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
-------------------------------------------------
"It may be true that the law cannot make a man love me,
but it can keep him from lynching me,
and I think that's pretty important."
-- Martin Luther King, Jr.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-01-08 10:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-08 9:42 ~ substitution sergio
2011-01-08 10:35 ` Guillaume Brunerie
2011-01-08 10:42 ` Mikael Magnusson
2011-01-08 10:44 ` Atom Smasher
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).