Variable is not changing from subshell
There is a simple code to demonstrate the problem:
[kan@altegom ~]$ ( A=1; ls | if true; then A=2; fi; echo $A; )
1
I expect output 2, but because the if is executed in pipe (I think it
instantiates a new shell), the variable assignment is not visible.
How could I change a variable from a pipe?
No comments:
Post a Comment