Re: bash scripting arcana
On Tue, 30 Jul 2002, Michael O'Donnell wrote: = =Today I ran across this usage of the 'Process Substitution' trickery =supported by BASH: = = = { command1 ; command2 ; command3 } ( tee -a $someLogFile ) 21 This doesn't look legal. Period. = = =...and wondered how it differs from (or is preferable to) this: = = = { command1 ; command2 ; command3 } | ( tee -a $someLogFile ) 21 This is also illegal unless you are running a really old version of bash. The last cmd inside the braces needs to be terminated by a semicolon: { command1 ; command2 ; command3; } | ( tee -a $someLogFile ) 21 The tee command is being executed inside a subshell for no good reason that I can discern and the stderr of the tee is duped to stdout, except that tee produces nothing to stderr. Also note that is not a legal parse. If you're going to append to a file, you must use the two angle brackets together: = = =Probably some subtle named-pipe versus unnamed-pipe difference, ya? = = =If you haven't messed with this 'Process Substitution' stuff =before, examples like the following could (as my favorite oracle =might say) bake your noodle: = = ls -l ( echo ) = echo ( ls -l ) = =...my noodle is currently al dente. (I mean, all denty...) -- -Time flies like the wind. Fruit flies like a banana. Stranger things have - -happened but none stranger than this. Does your driver's license say Organ -Donor?Black holes are where God divided by zero. Listen to me! We are all- -individuals! What if this weren't a hypothetical question? [EMAIL PROTECTED] * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: bash scripting arcana
2.05a.0(1)-release ] = { command1 ; command2 ; command3 } ( tee -a $someLogFile ) 21 ] ] This doesn't look legal. Period. Heh. Like I said, it'll bake your noodle - that's what got me to dig further. It is indeed a legal construct, part of something the BASH docs call 'Process Substitution' - check the man page. And, no - it's not a botched append operation; that's what I thought at first, too. Try the examples... * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: bash scripting arcana
In a message dated: Tue, 30 Jul 2002 18:07:18 EDT Michael O'Donnell said: If you haven't messed with this 'Process Substitution' stuff before, examples like the following could (as my favorite oracle might say) bake your noodle: ls -l ( echo ) echo ( ls -l ) ...my noodle is currently al dente. (I mean, all denty...) Mine is pretty well cooked now: pll@tater:~$ ls -l ( echo ) lr-x-- 1 pll pll 64 Jul 31 10:02 /dev/fd/63 - pipe:[5071] pll@tater:~$ echo ( ls -l ) /dev/fd/63 Definitely not what I expected at all. Especially considering pll@tater:~$ ls -l /dev/fd/ total 0 lrwx--1 pll pll64 Jul 31 10:14 0 - /dev/pts/1 lrwx--1 pll pll64 Jul 31 10:14 1 - /dev/pts/1 lrwx--1 pll pll64 Jul 31 10:14 2 - /dev/pts/1 lr-x--1 pll pll64 Jul 31 10:14 3 - /proc/1461/fd -- Seeya, Paul -- It may look like I'm just sitting here doing nothing, but I'm really actively waiting for all my problems to go away. If you're not having fun, you're not doing it right! * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: bash scripting arcana
pll@tater:~$ ls -l ( echo ) lr-x-- 1 pll pll 64 Jul 31 10:02 /dev/fd/63 - pipe:[5071] pll@tater:~$ echo ( ls -l ) /dev/fd/63 Definitely not what I expected at all. Especially considering pll@tater:~$ ls -l /dev/fd/ total 0 lrwx-- 1 pll pll 64 Jul 31 10:14 0 - /dev/pts/1 lrwx-- 1 pll pll 64 Jul 31 10:14 1 - /dev/pts/1 lrwx-- 1 pll pll 64 Jul 31 10:14 2 - /dev/pts/1 lr-x-- 1 pll pll 64 Jul 31 10:14 3 - /proc/1461/fd Heh. You're in a maze of twisty little passages... I think you're (at least partly) being faked out by some of the symlinks in question: # ls -lad /dev/fd /proc/self lrwxrwxrwx 1 root root 13 Apr 6 14:39 /dev/fd- /proc/self/fd lrwxrwxrwx 1 root root 64 Jul 31 08:09 /proc/self - 4016 ...but those are just decoys intended to prevent understanding. Here's what the BASH man page says about 'Process Substitution': Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of (list) or (list). The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the (list) form is used, writing to the file will provide input for list. If the (list) form is used, the file passed as an argument should be read to obtain the output of list. * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: bash scripting arcana
On Wed, 2002-07-31 at 11:07, Michael O'Donnell wrote: [snip] Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of (list) or (list). The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the (list) form is used, writing to the file will provide input for list. If the (list) form is used, the file passed as an argument should be read to obtain the output of list. So this is like the =(list) construct in the Z shell? I'm liking it more and more. That and in-line mult-line command editing are two things I've always liked about zsh that were missing in bash. Now bash has 'shopt -s lithist' that comes real close to the way zsh works with multi-line commands. So anyone know when process substitution was introduced into bash? Just curious. -- -Paul Iadonisi Senior System Administrator Red Hat Certified Engineer / Local Linux Lobbyist Ever see a penguin fly? -- Try Linux. GPL all the way: Sell services, don't lease secrets * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *
Re: bash scripting arcana
So anyone know when process substitution was introduced into bash? I see it supported at least as far back a 1.14.6 and I suspect it's been around much longer. * To unsubscribe from this list, send mail to [EMAIL PROTECTED] with the text 'unsubscribe gnhlug' in the message body. *