[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arithmetic expansion with increments and output redirection

From: Robert Elz
Subject: Re: Arithmetic expansion with increments and output redirection
Date: Wed, 24 Apr 2019 15:59:37 +0700

    Date:        Tue, 23 Apr 2019 15:49:18 -0600
    From:        Ian Neal <address@hidden>
    Message-ID:  <address@hidden>

  | When using arithmetic expansion with variable pre- and
  | post-increments/decrements in the output redirection file path,
  | specifically on external executables (not builtins or functions), the state
  | of the variable being incremented/decremented is not persisted in the
  | environment.

That is as it should be, redirects are eveluated in the sub-shell
context.   If anything the bug you showed is that redirects when the
shell does not fork are being evaluated in the context of the shell
(but I think that might be an unspecified case).

In general it is best not to even consider using any evaluation with
side effects in any redirection, and unless you really consider what
you're doing, not in var-assigns either (there, if you're not expecting
the side effects to be visible in the same, or any other, assignemnt
in the same command you should be OK).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]