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

Re: [PATCH] respect nullglob given multios



On Thu, 2019-10-10 at 01:18 +0000, Joe Rice wrote:
> This patch makes multios behave less surprisingly with nullglob.
>
> Currently, multios throws a file not found error when a nullglob is
> given. This patch inserts /dev/null into the redirection list when the
> glob returns empty with no errors.
>
> Is this a behavior that would interest anyone else? I find myself
> using the `cat /dev/null *(N.)` idiom quite a bit and I thought the
> behavior made sense for the null case in multios.

This does seem a logical effect, though it ought to be documented.

pws

diff --git a/Doc/Zsh/redirect.yo b/Doc/Zsh/redirect.yo
index 13496d8d3..76bc23efe 100644
--- a/Doc/Zsh/redirect.yo
+++ b/Doc/Zsh/redirect.yo
@@ -277,7 +277,10 @@ all the specified inputs to its output in the order specified, provided
 the tt(MULTIOS) option is set.  It should be noted that each file is
 opened immediately, not at the point where it is about to be read:
 this behaviour differs from tt(cat), so if strictly standard behaviour
-is needed, tt(cat) should be used instead.
+is needed, tt(cat) should be used instead.  If the option tt(NULL_GLOB)
+is set and filename generation produces no files, redirection is
+instead performed from tt(/dev/null), so that there is a valid, but
+empty, input stream.
 
 Thus
 



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