Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Question about expansion: redirection(<) vs command(cat)



Hi everyone,

I'm trying to understand why, in the following case, expansion doesn't occur with redirection.

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 $?
Note: I tried several forms of expansion, all failed.

When using 'cat' expansion happens as expected.
Array=(${(f)"$(cat /usr/share/zsh/<->.*/scripts/newuser)"}) ; print $?

The man page has the following:

       The following may appear anywhere in a simple command or may precede  or
       follow a complex command.  Expansion occurs before word or digit is used
       except  as  noted below.  If the result of substitution on word produces
       more than one filename, redirection occurs for each separate filename in
       turn.

       < word Open file word for reading as standard input.  It is an error  to
              open a file in this fashion if it does not exist.

Am I missing something in the man page information shown above?

Any help in understanding what is happening would be appreciated.

Thanks, and Regards,

Jim Murphy


Messages sorted by: Reverse Date, Date, Thread, Author