Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Question about expansion: redirection(<) vs command(cat)
- X-seq: zsh-users 30424
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: linuxtechguy@xxxxxxxxx
- Cc: zsh <zsh-users@xxxxxxx>
- Subject: Re: Question about expansion: redirection(<) vs command(cat)
- Date: Tue, 13 Jan 2026 13:18:59 -0800
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PfkXzbKzckKB+geLh6FRVg8ClIWP5e2M17oF2gb69zU=; fh=u3fRZMHQrD0jPYg6dsc8wabkr4a8OQ2n3ZBvRt2081o=; b=OeIQcer9oDMm2HoRis16sZX1637Lu9pS/SpFQqw0bVrtjbkpHTBBkKNp947/23ZFpZ NDwn3jXF9qpsdUc51pbTuSCxExaHcHoZzKPK9zep5OyiTYiNba85SrmOzHJaV4d1yOdW IUVw7p2STNrNQYDN6czA7gAqqLNn0t1F/Z+7urm3sty5xEv/ckudb4g84VMvDxVfPgYQ +sdm2YBu8r6tXtHxC8ZMSqbZUS3N6hD05V/jwWgPvP37RJ/KTTLtp4Jb1GhS7R5Gs2kP P4635laaDw0dyJ/gUJDU2aVOAUsiWURzm1vbwzm+ehL5cCjHYWBeHFHVCpUbwSMR+B5V SUIQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1768339151; cv=none; d=google.com; s=arc-20240605; b=kqGE7bOLdOPELSTE+H5dBBWJY1IzbTpAkzUq25JBS5XDtE2Nsv8IL+9VLS0Bey/C02 UmApDCHBWhHT9vL/qCGWp5kgetbbaaTEOAZa9wkwiVaaqqoLlvVvviYbMEBvQNJsIb5G +AGUkFpdp/BQ1RyUiaEjEDCO6me5R0T7qn1z3weRk6VZHK3hzSGsHRTMSPz9tMyXWuxI ZMgNmqKHkuhXL1cG4jwTSw9At+pe13MO+/i4idr4q3HQLDtHbP/Ep1cL0HqqH5WCSHNz VjkB8UjLyd0sYwEAeoJZ7LWTBDSSAFDfqhLZcK0HT7mHQZjTeqc3fwRX0kURq+vuIIW0 AaPg==
- Archived-at: <https://zsh.org/users/30424>
- In-reply-to: <CA+rB6GLcMFBOKZ4XEdn524-CCgg0Rdg+N7DEAMz85v1VjNDmEQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CA+rB6GLcMFBOKZ4XEdn524-CCgg0Rdg+N7DEAMz85v1VjNDmEQ@mail.gmail.com>
On Tue, Jan 13, 2026 at 11:09 AM Jim <linux.tech.guy@xxxxxxxxx> 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".
Messages sorted by:
Reverse Date,
Date,
Thread,
Author