Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Use glob patterns while reading a file
- X-seq: zsh-workers 43820
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: Use glob patterns while reading a file
- Date: Mon, 12 Nov 2018 10:14:08 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181112101410euoutp027b97d54e5598fd753c395d02b3b8905d~mWOIlXVns2028820288euoutp02h
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1542017650; bh=p7wxbg59vXdIRZ0cl6A80OfZ6ZXyIfgU/jfpDFt0HwU=; h=Subject:From:To:Date:In-Reply-To:References:From; b=TGTQ1548r/f/0hDw2SB97q4uFV/gh5VJCh7TpI4ataP99QVwuj3BMwyBE9GaZ7vff GuQb+OFtfEGOAfnvxkczHTjosJx6IpXgH6ZRNE5f9fyLdD2AMvPqoPR3MdxSDQ/mMO g+W/eTcHHUTnEQoJIkb4iKa30TlkvpRY7cSUf8oA=
- In-reply-to: <CAH+w=7Y6t1u-q-5ioxPCKw3Cu+VCoErfypSyU+NJ_Ov9fWFq+A@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20181108225555epcas2p274de218aef35e46f189ebbfbd9d1892f@epcas2p2.samsung.com> <CAJjRh0SROuSoc4f+3bqLNsc+iASx7MRULrNWqdPjK+MKFHys7A@mail.gmail.com> <1541756153.3720.1.camel@samsung.com> <1541812878.2985396.1571973512.684C1909@webmail.messagingengine.com> <CAH+w=7YuTY2W6R=tOrD+DijiiboQxJ-EDRROxhB05+gwwQEgRg@mail.gmail.com> <CAH+w=7Y6t1u-q-5ioxPCKw3Cu+VCoErfypSyU+NJ_Ov9fWFq+A@mail.gmail.com>
Certainly $(<...) was always intended to make it easier to get hold of a
single file, so has never done globbing (which would logically imply
multios, if the option is on), although I'm not aware of any fundamental
reason why it would break anything if it did (the implementation is
actually rather different from normal redirection as the file is simply
read in bodily).
However, the documentation does say it's equivalent to using the cat
command, which isn't true if var(foo) has globbing characters in it ---
I presume when the manual entry was written nobody considered it might.
The sentence after is also a bit unclear --- I'm not sure which the two
cases referred to are, but I presume they're unquoted $(...) with a
normal command and unquoted $(<...). As the case of double quotes is
mentioned (although in the negative) in between, this doesn't seem
ideal.
It doesn't explicitly say what happens if the expressions is quoted,
though it does imply the final newlines are removed in any case so I
suppose there's enough to go on.
Any number of trailing newlines are removed, not just one. I suppose
"any trailing newlines" (plural) does cover that.
pws
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index c791097..fbcf5d1 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -1683,10 +1683,17 @@ any trailing newlines deleted.
If the substitution is not enclosed in double quotes, the
output is broken into words using the tt(IFS) parameter.
vindex(IFS, use of)
+
The substitution `tt($LPAR()cat) var(foo)tt(RPAR())' may be replaced
-by the equivalent but faster `tt($LPAR()<)var(foo)tt(RPAR())'.
-In either case, if the option tt(GLOB_SUBST) is set,
-the output is eligible for filename generation.
+by the faster `tt($LPAR()<)var(foo)tt(RPAR())'. In this case var(foo)
+undergoes single word shell expansions (em(parameter expansion),
+em(command substitution) and em(arithmetic expansion)), but not
+filename generation.
+
+If the option tt(GLOB_SUBST) is set, the result of any unquoted command
+substitution, including the special form just mentioned, is eligible for
+filename generation.
+
texinode(Arithmetic Expansion)(Brace Expansion)(Command Substitution)(Expansion)
sect(Arithmetic Expansion)
cindex(arithmetic expansion)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author