From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: export "a=b"=~
Date: Wed, 8 Mar 2017 22:30:03 +0000 [thread overview]
Message-ID: <20170308223003.GC21381@chaz.gmail.com> (raw)
In-Reply-To: <20170308154428.466197e9@pwslap01u.europe.root.pri>
2017-03-08 15:44:28 +0000, Peter Stephenson:
[...]
> > Same behaviour in latest master. This is because the MAGIC_EQUAL_SUBST
> > option, even when unset, implicitly applies to "export". (The
> > declaration of "export" in builtins.c has the BINF_MAGICEQUALS flag
> > since before CVS.)
[...]
> So I think the following ought to work without any significant side
> effects. I've renamed the controlling variable for clarity; the older,
> more general, name is now purely historical.
[...]
Some variations between shells:
$ ksh93 -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
/home/chazelas
~
/home/chazelas
~
$ bash -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
/home/chazelas
~
/home/chazelas
~
$ ARGV0=sh bash -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
/home/chazelas
~
~
~
$ mksh -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
/home/chazelas
/home/chazelas
/home/chazelas
~
$ dash -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
~
~
~
~
$ yash -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
~
~
~
~
$ zsh -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
/home/chazelas
/home/chazelas
~
~
$ zsh -o magicequalsubst -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
/home/chazelas
/home/chazelas
/home/chazelas
~
After your patch:
$ ./Src/zsh -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
/home/chazelas
~
~
~
$ ./Src/zsh -o magicequalsubst -c 'export a=~; echo $a; export "a"=~; echo $a; "export" a=~; echo $a; export a\=~; echo $a'
/home/chazelas
~
/home/chazelas
~
I can't say I have a strong opinion on what is best. I like
magic_equal_subst myself and I'm annoyed when ./configure
--prefix=~ doesn't work or sudo JAVA_HOME=~/jre... And I tend to
quote ~ when in doubt and don't want it to be expanded.
Note that in bash (when not in posix mode)
echo a=~
expands (so covers my sudo case above) but
echo --prefix=~
does not. What's on the left of the = has to look like a valid
literal unquoted bash variable name.
Started from:
https://askubuntu.com/questions/890415/why-couldnt-i-use-instead-of-home-username-when-giving-the-file-pat/890472#890472
--
Stephane
prev parent reply other threads:[~2017-03-08 22:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 8:50 Stephane Chazelas
2017-03-08 13:23 ` Daniel Shahaf
2017-03-08 15:44 ` Peter Stephenson
2017-03-08 22:30 ` Stephane Chazelas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170308223003.GC21381@chaz.gmail.com \
--to=stephane.chazelas@gmail.com \
--cc=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).