aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-03-09 11:26:07 +0000
committerng0 <ng0@n0.is>2019-03-09 11:26:07 +0000
commitcc372c3427454e52763b22461fd3af1aaaf295d3 (patch)
treedf5786f2f5d77f67558dfdca6e39aa86870d6a53 /src
parent3d05b5cc48632ad200fe7117386d9fdb96bf4647 (diff)
downloadgnunet-cc372c3427454e52763b22461fd3af1aaaf295d3.tar.gz
gnunet-cc372c3427454e52763b22461fd3af1aaaf295d3.zip
cadet/loopcheck.sh: still bash, leaving only PIPESTATUS
Diffstat (limited to 'src')
-rwxr-xr-xsrc/cadet/loopcheck.sh42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/cadet/loopcheck.sh b/src/cadet/loopcheck.sh
index ddc8c191c..9b867e95b 100755
--- a/src/cadet/loopcheck.sh
+++ b/src/cadet/loopcheck.sh
@@ -1,4 +1,41 @@
1#!/bin/sh 1#!/usr/bin/env bash
2# This script is in the public domain
3# POSIX shell solution for named pipes and pipestatus,
4# http://shell.cfajohnson.com/cus-faq-2.html#Q11
5# run() {
6# j=1
7# while eval "\${pipestatus_$j+:} false"; do
8# unset pipestatus_$j
9# j=$(($j+1))
10# done
11# j=1 com= k=1 l=
12# for a; do
13# if [ "x$a" = 'x|' ]; then
14# com="$com { $l "'3>&-
15# echo "pipestatus_'$j'=$?" >&3
16# } 4>&- |'
17# j=$(($j+1)) l=
18# else
19# l="$l \"\$$k\""
20# fi
21# k=$(($k+1))
22# done
23# com="$com $l"' 3>&- >&4 4>&-
24# echo "pipestatus_'$j'=$?"'
25# exec 4>&1
26# eval "$(exec 3>&1; eval "$com")"
27# exec 4>&-
28# j=1
29# while eval "\${pipestatus_$j+:} false"; do
30# eval "[ \$pipestatus_$j -eq 0 ]" || return 1
31# j=$(($j+1))
32# done
33# return 0
34# }
35
36# # https://mywiki.wooledge.org/Bashism has another solution:
37# # mkfifo fifo; command2 <fifo & command1 >fifo; echo "$?"
38
2while true; do 39while true; do
3 if [ "$1" = "" ]; then 40 if [ "$1" = "" ]; then
4 echo All 41 echo All
@@ -7,6 +44,7 @@ while true; do
7 echo One 44 echo One
8 LOGFILE="test_`date "+%m.%d-%H:%M:%S"`.log" 45 LOGFILE="test_`date "+%m.%d-%H:%M:%S"`.log"
9 taskset 01 $1 2>&1 | tee $LOGFILE | grep -v DEBUG; 46 taskset 01 $1 2>&1 | tee $LOGFILE | grep -v DEBUG;
47 # TODO: Replace $PIPESTATUS with more portable code
10 if [ "${PIPESTATUS[0]}" != "0" ]; then 48 if [ "${PIPESTATUS[0]}" != "0" ]; then
11 echo "Failed"; 49 echo "Failed";
12 date; 50 date;
@@ -15,5 +53,5 @@ while true; do
15 fi 53 fi
16 grep cadet test_*.log | grep -B 10 ERROR && break 54 grep cadet test_*.log | grep -B 10 ERROR && break
17 grep cadet test_*.log | grep -B 10 Assert && break 55 grep cadet test_*.log | grep -B 10 Assert && break
18 ls core* &> /dev/null && break 56 ls core* > /dev/null 2>&1 && break
19done 57done