Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: export "a=b"=~
- X-seq: zsh-workers 40798
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: export "a=b"=~
- Date: Wed, 8 Mar 2017 22:30:03 +0000
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9bKh47IySnoBDdVgQEsMOoyX/qum5epyv6B9SslutUE=; b=pnpikYnKyEufUVC0kuy/xVSAzgzEx3+2CPMHdimTbnVYEoITVeoWxVhv87nVBEbauL L2phETupmjsgl4+CDgDV38DxkV9QMuL5QSF3MCELxvJ42wzNqDVqHhkt7h4KbjkNPYDT nKC+RM2L9qawSw8Vwiml4k+VPxShGhvEzSrspHxBBOjvDEzcFikd34CpT+SKmDOgl1ko he/mSIuhr9jog69lQA9iSTD7lr1ppvkocTjsItCi3lAoNV6DZwYD7v8oIqezykvBx7kD zrwQ0i4fIrztEkLPc/oflmqFWjH12YAOPsjD4xPKHnjDoPrl1+/E/rIWdLNbBF25wqO6 3ltA==
- In-reply-to: <20170308154428.466197e9@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Peter Stephenson <p.stephenson@xxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20170308085000.GA6975@chaz.gmail.com> <CGME20170308132910epcas1p33144f6d5af5a6983019959a010930e83@epcas1p3.samsung.com> <20170308132345.GA18254@fujitsu.shahaf.local2> <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author