Hello, a strange behaviour of while with bash 4.0.28 :
$ A=1 ; while [ $A -lt 4 ] ; do A=$((A+1)); echo $A ; done ; echo $A
$ A=1 ; cat foobar |while [ $A -lt 4 ] ; do A=$((A+1)); echo $A ; done ; echo $A
My first question : after a pipe, while
does'nt keep the value for variable $A. Why ?
My second question : dash behaves like bash, but zsh and ksh have a more "normal" behaviour : the 2 variants end with $A=4.
Is there a good reason ? Posix compatibility or somewhat ?
is a real file, but it's the same if it doesn't exist)