Re: Arithmetic expansion with increments and output redirection
From:
Greg Wooledge
Subject:
Re: Arithmetic expansion with increments and output redirection
Date:
Wed, 24 Apr 2019 08:53:04 -0400
User-agent:
Mutt/1.10.1 (2018-07-13)
On Wed, Apr 24, 2019 at 06:47:41AM -0600, Ian Neal wrote:
> 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.
The context got snipped but IIRC it was something like
/bin/true > $((n++))
The /bin/true forces the use of an external command, which means a subshell
is forked. The redirection occurs in the forked subshell.