reduce: use if() to test for exit status of pipeline
The new rc's exit status will be '' for a successfull pipeline execution instead of '|'. This is a bit too tightly coupled, so just use if() statement instead, handling this in a portable way.
This commit is contained in:
parent
4d872079d3
commit
85bfb0e9eb
4 changed files with 24 additions and 40 deletions
|
@ -2,15 +2,11 @@ O=$1
|
||||||
shift
|
shift
|
||||||
objtype=$1
|
objtype=$1
|
||||||
shift
|
shift
|
||||||
|
if(ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//;s/^/^/' > /tmp/reduce.$pid) {
|
||||||
ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//;s/^/^/' > /tmp/reduce.$pid
|
|
||||||
#
|
|
||||||
# if empty directory, just return the input files
|
|
||||||
#
|
|
||||||
if (! ~ $status '|') {
|
|
||||||
echo $*
|
|
||||||
rm /tmp/reduce.$pid
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
|
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
|
||||||
|
}
|
||||||
|
if not {
|
||||||
|
# if empty directory, just return the input files
|
||||||
|
echo $*
|
||||||
|
}
|
||||||
rm /tmp/reduce.$pid
|
rm /tmp/reduce.$pid
|
||||||
|
|
|
@ -2,15 +2,11 @@ O=$1
|
||||||
shift
|
shift
|
||||||
objtype=$1
|
objtype=$1
|
||||||
shift
|
shift
|
||||||
|
if(ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//;s/^/^/' > /tmp/reduce.$pid) {
|
||||||
ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//;s/^/^/' > /tmp/reduce.$pid
|
|
||||||
#
|
|
||||||
# if empty directory, just return the input files
|
|
||||||
#
|
|
||||||
if (! ~ $status '|') {
|
|
||||||
echo $*
|
|
||||||
rm /tmp/reduce.$pid
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
|
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
|
||||||
|
}
|
||||||
|
if not {
|
||||||
|
# if empty directory, just return the input files
|
||||||
|
echo $*
|
||||||
|
}
|
||||||
rm /tmp/reduce.$pid
|
rm /tmp/reduce.$pid
|
||||||
|
|
|
@ -2,15 +2,11 @@ O=$1
|
||||||
shift
|
shift
|
||||||
objtype=$1
|
objtype=$1
|
||||||
shift
|
shift
|
||||||
|
if(ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//;s/^/^/' > /tmp/reduce.$pid) {
|
||||||
ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$pid
|
|
||||||
#
|
|
||||||
# if empty directory, just return the input files
|
|
||||||
#
|
|
||||||
if (! ~ $status '|') {
|
|
||||||
echo $*
|
|
||||||
rm /tmp/reduce.$pid
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
|
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
|
||||||
|
}
|
||||||
|
if not {
|
||||||
|
# if empty directory, just return the input files
|
||||||
|
echo $*
|
||||||
|
}
|
||||||
rm /tmp/reduce.$pid
|
rm /tmp/reduce.$pid
|
||||||
|
|
|
@ -2,15 +2,11 @@ O=$1
|
||||||
shift
|
shift
|
||||||
objtype=$1
|
objtype=$1
|
||||||
shift
|
shift
|
||||||
|
if(ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//;s/^/^/' > /tmp/reduce.$pid) {
|
||||||
ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$pid
|
|
||||||
#
|
|
||||||
# if empty directory, just return the input files
|
|
||||||
#
|
|
||||||
if (! ~ $status '|') {
|
|
||||||
echo $*
|
|
||||||
rm /tmp/reduce.$pid
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
|
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
|
||||||
|
}
|
||||||
|
if not {
|
||||||
|
# if empty directory, just return the input files
|
||||||
|
echo $*
|
||||||
|
}
|
||||||
rm /tmp/reduce.$pid
|
rm /tmp/reduce.$pid
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue