Re: bash: request for a way to return variables to the parent of a subshell

2008-07-22 Thread Richard Neill
Thank you. That's a really neat solution - and it would never have occurred to me. I always think from left to right! Richard Paul Jarc wrote: Richard Neill <[EMAIL PROTECTED]> wrote: the aim is to parse the output of "ffmpeg -formats" to see whether certain codecs are supported by that bui

Re: bash: request for a way to return variables to the parent of a subshell

2008-07-22 Thread Paul Jarc
Richard Neill <[EMAIL PROTECTED]> wrote: > the aim is to parse the output of "ffmpeg -formats" to see whether > certain codecs are supported by that build. I'd use something like: while read line; do ... done < <(ffmpeg -formats 2>/dev/null) That puts ffmpeg into a subshell instead of read. p

Re: bash: request for a way to return variables to the parent of a subshell

2008-07-22 Thread Richard Neill
Dear Eric, Thank you for your helpful answer. I'd understood that bash *doesn't* pass info back from the child to the parent, but I didn't realise that it was fundamentally *impossible* to do in Unix. I guess that tempfiles would do it - though that's rather ugly. Is there any way to use "re

Re: bash: request for a way to return variables to the parent of a subshell

2008-07-22 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Richard Neill on 7/22/2008 8:04 PM: | This prints "Match-1", but does not print "Match-2". | | The only way to get data out of the read-subshell is by something like | "exit 2", and looking at $? You can also use files. The position wit

Re: bash: request for a way to return variables to the parent of a subshell

2008-07-22 Thread Chris F.A. Johnson
On 2008-07-23, Richard Neill wrote: > At the moment, variables set within a subshell can never be accessed by > the parent script. This is true, even for an implicit subshell such as > caused by read. The subshell is caused by the ipe, not by read. > For example, consider the following (sli