Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Why does >&- produce an error message when connected to a builtin? (was Re: (N) defaults to whole directory listing)
- X-seq: zsh-users 26776
- From: Marlon Richert <marlon.richert@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>, Ray Andrews <rayandrews@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Why does >&- produce an error message when connected to a builtin? (was Re: (N) defaults to whole directory listing)
- Date: Fri, 18 Jun 2021 13:24:32 +0300
- Archived-at: <https://zsh.org/users/26776>
- In-reply-to: <CAH+w=7bN7miEudLZcLknDQH3im=u8CCe_3GUqtEJMtyidV8bUg@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <d611ab66-c6f9-655f-89dc-ded8697fe0ed@eastlink.ca> <CAN=4vMp+JykOWEYQ5qO495-hOpQXh+4RN6iHcYTP-APg8XHESQ@mail.gmail.com> <CAH+w=7bN7miEudLZcLknDQH3im=u8CCe_3GUqtEJMtyidV8bUg@mail.gmail.com>
On Fri, Jan 29, 2021 at 9:05 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Fri, Jan 29, 2021 at 7:33 AM Roman Perepelitsa
> <roman.perepelitsa@xxxxxxxxx> wrote:
> >
> > ( ls -1 no_such_file(#q) ) 2>/dev/null
>
> That can be done without a subshell:
>
> { ls no_such_file(#q) } 2>&-
Why does >&- produce an error message when connected to a builtin,
rather than an external command?
% print -qqq
print: bad option: -q
% git -qqq
unknown option: -qqq
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
% print -qqq 2>&-
zsh: write error
% git -qqq 2>&-
%
And for the cases below, why does it produce an error message for the
former, but not for the latter?
% { print -qqq } 2>&-
zsh: write error
% { print no_such_file(#q); print -qqq } 2>&-
%
Is this an intended or unintended difference?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author