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:
cinap_lenrek 2022-01-10 02:01:11 +00:00
parent 4d872079d3
commit 85bfb0e9eb
4 changed files with 24 additions and 40 deletions

View file

@ -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 echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
# }
# if empty directory, just return the input files if not {
# # if empty directory, just return the input files
if (! ~ $status '|') { echo $*
echo $*
rm /tmp/reduce.$pid
exit 0
} }
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
rm /tmp/reduce.$pid rm /tmp/reduce.$pid

View file

@ -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 echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
# }
# if empty directory, just return the input files if not {
# # if empty directory, just return the input files
if (! ~ $status '|') { echo $*
echo $*
rm /tmp/reduce.$pid
exit 0
} }
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
rm /tmp/reduce.$pid rm /tmp/reduce.$pid

View file

@ -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 echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
# }
# if empty directory, just return the input files if not {
# # if empty directory, just return the input files
if (! ~ $status '|') { echo $*
echo $*
rm /tmp/reduce.$pid
exit 0
} }
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
rm /tmp/reduce.$pid rm /tmp/reduce.$pid

View file

@ -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 echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
# }
# if empty directory, just return the input files if not {
# # if empty directory, just return the input files
if (! ~ $status '|') { echo $*
echo $*
rm /tmp/reduce.$pid
exit 0
} }
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
rm /tmp/reduce.$pid rm /tmp/reduce.$pid