git: 9front

Download patch

ref: ddda6f55473c808cb379484b30badb60bc4daab0
parent: f840c4a993b850737e67dda8c280ec1eb6b75f04
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jan 9 21:01:11 EST 2022

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.

--- a/sys/src/ape/lib/ap/gen/reduce
+++ b/sys/src/ape/lib/ap/gen/reduce
@@ -2,15 +2,11 @@
 shift
 objtype=$1
 shift
-
-ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//;s/^/^/' > /tmp/reduce.$pid
-#
-#	if empty directory, just return the input files
-#
-if (! ~ $status '|') {
+if(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 not {
+	# if empty directory, just return the input files
 	echo $*
-	rm /tmp/reduce.$pid
-	exit 0
 }
-echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
 rm /tmp/reduce.$pid
--- a/sys/src/libc/port/reduce
+++ b/sys/src/libc/port/reduce
@@ -2,15 +2,11 @@
 shift
 objtype=$1
 shift
-
-ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//;s/^/^/' > /tmp/reduce.$pid
-#
-#	if empty directory, just return the input files
-#
-if (! ~ $status '|') {
+if(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 not {
+	# if empty directory, just return the input files
 	echo $*
-	rm /tmp/reduce.$pid
-	exit 0
 }
-echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
 rm /tmp/reduce.$pid
--- a/sys/src/libmp/port/reduce
+++ b/sys/src/libmp/port/reduce
@@ -2,15 +2,11 @@
 shift
 objtype=$1
 shift
-
-ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$pid
-#
-#	if empty directory, just return the input files
-#
-if (! ~ $status '|') {
+if(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 not {
+	# if empty directory, just return the input files
 	echo $*
-	rm /tmp/reduce.$pid
-	exit 0
 }
-echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
 rm /tmp/reduce.$pid
--- a/sys/src/libsec/port/reduce
+++ b/sys/src/libsec/port/reduce
@@ -2,15 +2,11 @@
 shift
 objtype=$1
 shift
-
-ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$pid
-#
-#	if empty directory, just return the input files
-#
-if (! ~ $status '|') {
+if(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 not {
+	# if empty directory, just return the input files
 	echo $*
-	rm /tmp/reduce.$pid
-	exit 0
 }
-echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
 rm /tmp/reduce.$pid
--