Re: Process substitution gives error in script
- From: Jeenu <jeenuv@xxxxxxxxx>
- Date: Sat, 3 Jan 2009 20:59:10 -0800 (PST)
On Jan 4, 1:45 am, Stephane CHAZELAS <stephane_chaze...@xxxxxxxx>
wrote:
Process substitution is piping and spawns a subshell as well.
In foo | bar, which end of the pipe is in a subshell or not
depends on the shell.
Consider this: I want to analyze the output of a command, say, ls.
AFAIU, I can do either
ls |
while read line; do
# some test on $line fails
exit
done
OR
while read line; do
# some test on $line fails
exit
done < <(ls)
OR
ls > ls.output
while read line; do
# some test on $line fails
exit
done <ls.output
Speaking about portability: first one is highly intuitive. But where
the exit command runs depends on how shell implements piping, and
hence is not portable. Second one is not portable either for the
process-substitution; but the exit command sure runs on the main
script. So does it mean that all scripts that make use of piping and
process-substitution are not portable?
Third one, probably yes. But I don't see any performance gain across
the scripts. All of them incur running another program and reading its
output.
Given that I have a "#!/bin/bash" as the first line, and all bash
versions are consistent in implementation, isn't my script portable
enough? I'm not sure if I understand the true meaning of portability.
:-j
.
- Follow-Ups:
- Re: Process substitution gives error in script
- From: Stephane CHAZELAS
- Re: Process substitution gives error in script
- From: Chris F.A. Johnson
- Re: Process substitution gives error in script
- References:
- Process substitution gives error in script
- From: Jeenu
- Re: Process substitution gives error in script
- From: Steffen Schuler
- Re: Process substitution gives error in script
- From: Stephane CHAZELAS
- Re: Process substitution gives error in script
- From: Jeenu
- Re: Process substitution gives error in script
- From: Stephane CHAZELAS
- Process substitution gives error in script
- Prev by Date: Re: Finding links to other mounts
- Next by Date: Re: Process substitution gives error in script
- Previous by thread: Re: Process substitution gives error in script
- Next by thread: Re: Process substitution gives error in script
- Index(es):
Relevant Pages
|