[Techtalk] weirdness piping to a variable

Miriam English mim at miriam-english.org
Sat Oct 19 09:20:31 UTC 2013


OMG this is brilliant! I have bash 4.1 so I'll upgrade to 4.2 which will 
give me exactly what I want. Thank you!

Best wishes,

	- Miriam

Peggy Russell wrote:
> Miriam,
>
> Just one more thing (I promise :-)). I just knew this should work.
> Yeh!
>
> In Bash 4.2, there is a new option called lastpipe. If set, the
> last command is not done in a subshell. So your pipeline command
> would work without the (). You need to turn job control off though.
>
> set +m; shopt -s lastpipe; echo 'quick brown fox' |
>                             cut -d' ' -f2 |
>                             read a; echo $a
>
> Please ignore the following if you already know:
>
> Bash version info
> 1) bash --version
> 2) bash variable BASH_VERSINFO
>
>     A) declare -p BASH_VERSINFO    # nice for quick debugging
>     B) if [[ ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -eq 2 ]]; then
>          echo okay; fi
>
> Just a quick tip. Bash has a builtin command, 'help'. Type 'help' and
> you'll see all the quick help you can get. So rather than wading through
> the bash manpage for say, the test or set options, type:
> 'help test' or 'help set'.
>
> Hope this helped.
> Peggy Russell
>
>

-- 
If you don't have any failures then you're not trying hard enough.
  - Dr. Charles Elachi, director of NASA's Jet Propulsion Laboratory
-----
Website: http://miriam-english.org
Blogs:   http://miriam-e.dreamwidth.org
          http://miriam-e.livejournal.com




More information about the Techtalk mailing list