On Thu, Apr 25, 2024, 23:03 Oğuz <oguzismailuy...@gmail.com> wrote:

> On Fri, Apr 26, 2024 at 1:17 AM Grisha Levit <grishale...@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.

>

Reply via email to