Re: Question about expansion: redirection(<) vs command(cat)
Bart Schaefer <[email protected]> Tue, 13 Jan 2026 13:18:59 -0800
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAH+w=7a_=uqSdRJuHtNzn-+BR72ice5zm-hQaXRt_H+4ucDNmQ@mail.gmail.com> |
On Tue, Jan 13, 2026 at 11:09 AM Jim <[email protected]> wrote: > > The following produced the expected output. > Array=(${(f)"$(< /usr/share/zsh/5.9/scripts/newuser)"}) ; print $? > > But when expansion is required the following fails. > Array=(${(f)"$(< /usr/share/zsh/<->.*/scripts/newuser)"}) ; print $? The issue here is that the token "$(<" is a special case of "$(" and not a special case of "<" redirection. Docs under "Command Substitution": The substitution '$(cat FOO)' may be replaced by the faster '$(<FOO)'. In this case FOO undergoes single word shell expansions (_parameter expansion_, _command substitution_ and _arithmetic expansion_), but not filename generation. No subshell is created. Note "but not filename generation".