Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: inconsistency between bash and zsh subshells
On 5/23/22, Matt Zagrabelny <mzagrabe@xxxxxxxxx> wrote:
> Greetings zsh-users,
>
> I'm using zsh 5.8.1 (Debian).
>
> I am seeing inconsistent behavior between using a subshell in the branch of
> a conditional in bash and zsh.
>
> zsh:
>
> zsh$ rm -f /tmp/FOO
> zsh$ ls /tmp/FOO 2> /dev/null || echo "no /tmp/FOO"
> no /tmp/FOO
> zsh$ echo | while read LINE; do IP=$(echo $LINE | cut -d ' ' -f 1); if [ -n
> "$IP" ]; then echo FOO; FOO=$(touch /tmp/FOO); else echo BAR; fi; done; ls
> /tmp/FOO 2> /dev/null || echo "no /tmp/FOO"
> BAR
> /tmp/FOO
>
> Why does the subshell in zsh get executed even though the conditional
> branch is not? That is, the "touch"-ing of /tmp/FOO.
You're most likely using a poorly written prompt theme and/or thing
that updates your terminal title. Try disabling that code and try
again if so.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author