[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Arithmetic expansion with increments and output redirection
From: |
Ian Neal |
Subject: |
Re: Arithmetic expansion with increments and output redirection |
Date: |
Wed, 24 Apr 2019 06:47:41 -0600 |
> Date: Tue, 23 Apr 2019 15:49:18 -0600
> From: Ian Neal <address@hidden>
> Message-ID: <CADBEB3qA0J1-j=iO5t_63h-Ksea1h6YGRnuU=
> 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).
>
> kre
>
At what point is a subshell being invoked? There's no pipeline, command
substitution, coprocess, background process, or explicit () subshell here,
which are the only cases a subshell should be created. Otherwise, the
entire operation should be evaluated by the main shell. Arithmetic
expansion is not in that list.
>
- Arithmetic expansion with increments and output redirection, Ian Neal, 2019/04/23
- Re: Arithmetic expansion with increments and output redirection, Robert Elz, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection,
Ian Neal <=
- Re: Arithmetic expansion with increments and output redirection, Greg Wooledge, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Andreas Schwab, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Chet Ramey, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Chet Ramey, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Ian Neal, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Chet Ramey, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Ilkka Virta, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Chet Ramey, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Greg Wooledge, 2019/04/24
- Re: Arithmetic expansion with increments and output redirection, Ian Neal, 2019/04/24