Re: Pipe using subshells, variables not saved

2017-03-06 Thread Chet Ramey
On 3/6/17 2:44 PM, Misaki wrote: > > On Sat, Mar 4, 2017 at 10:12 AM, Chet Ramey > wrote: > > On 3/4/17 1:04 AM, Misaki wrote: > > Variables are not saved when using a pipe because both sides are in a > > subshell environment. > > If you want this to

Re: Pipe using subshells, variables not saved

2017-03-06 Thread Misaki
On Sat, Mar 4, 2017 at 10:12 AM, Chet Ramey wrote: > On 3/4/17 1:04 AM, Misaki wrote: > > Variables are not saved when using a pipe because both sides are in a > > subshell environment. > > If you want this to happen, enable the `lastpipe' shell option. > Thank you. My standpoint is 'whatever ma

Re: Pipe using subshells, variables not saved

2017-03-06 Thread Greg Wooledge
On Fri, Mar 03, 2017 at 10:04:23PM -0800, Misaki wrote: > > reason for piping: > > echo wat | for i in $(< /dev/stdin); do declare -g new="$i"; done > > > > (using find instead of echo, not sure if better way to loop) while IFS= read -r file; do blah "$file"; done < <(find . -type f) That's compa

Re: Pipe using subshells, variables not saved

2017-03-04 Thread Chet Ramey
On 3/4/17 1:04 AM, Misaki wrote: > Variables are not saved when using a pipe because both sides are in a > subshell environment. If you want this to happen, enable the `lastpipe' shell option. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevi

Pipe using subshells, variables not saved

2017-03-03 Thread Misaki
Variables are not saved when using a pipe because both sides are in a subshell environment. A common place where a user may encounter this is when dealing with multiple items: bash bug?? > > Does not change the value of $new: > > echo hi| for i in 3; do new=3; done > > > reason for piping: > echo