[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [5.3-alpha] ">& /some/file" would fail when /some/file already exist
From: |
Grisha Levit |
Subject: |
Re: [5.3-alpha] ">& /some/file" would fail when /some/file already exists |
Date: |
Fri, 26 Apr 2024 03:42:17 -0400 |
On Thu, Apr 25, 2024, 23:03 Oğuz <oguzismailuysal@gmail.com> wrote:
> On Fri, Apr 26, 2024 at 1:17 AM Grisha Levit <grishalevit@gmail.com>
> wrote:
> > Actually, I see this on Ubuntu 22.04 but not on macOS.
> On Linux, O_EXCL and RX_EXPANDED (a flag used by bash to signal that
> the redirection word is already expanded) has the same value. I don't
> know why bash doesn't clear its internal flags before calling open.
>
Looks like RX_* values were previously used only to form the `flags'
argument of do_redirections() and related functions, comprising:
RX_ACTIVE RX_UNDOABLE RX_CLEXEC
Separately, the REDIRECTION struct has a `flags' member holding O_*
flags passed to open(). But the following (other) RX_* values are also
getting stored in the `flags' member of REDIRECTION structs:
RX_INTERNAL RX_USER RX_SAVCLEXEC RX_SAVEFD RX_EXPANDED
So as Oğuz notes, the issue here is observed when an RX_* value from
the above list has the same value as an O_* flag.
Perhaps it would make sense to change the latter set of RX_* values
into new REDIR_* values, which make up the `rflags' REDIRECTION member.
>
Re: [5.3-alpha] ">& /some/file" would fail when /some/file already exists, Clark Wang, 2024/04/25