From 5eb7ae6a194ec1b5f13d6e94a493b42e883af6dd Mon Sep 17 00:00:00 2001 From: Chris Fiege Date: Tue, 20 Nov 2018 22:06:51 +0100 Subject: [PATCH] telem-seq.sh: Make compatible to busybox sh busybox's sh-implementation is differnt from the normal sh: In busybox-expr an empty string does not evaluate to int(0). Calling `expr ($SEQ +1)` with `SEQ=""` fails. This patch works around this behavior by making sure the file exists. I left the pipe for stderr around the `cat` in place to make sure I do not break any other error cases. Signed-off-by: Chris Fiege --- telemetry-toolkit/telem-seq.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/telemetry-toolkit/telem-seq.sh b/telemetry-toolkit/telem-seq.sh index 0d2a36d..f904754 100644 --- a/telemetry-toolkit/telem-seq.sh +++ b/telemetry-toolkit/telem-seq.sh @@ -2,6 +2,10 @@ # Generate sequence number as described here: # https://github.com/wb2osz/direwolf/issues/9 # +if [ ! -f /tmp/seq ]; then +echo 0 > /tmp/seq +fi + SEQ=`cat /tmp/seq 2>/dev/null` SEQ=$(expr \( $SEQ + 1 \) % 1000) -echo $SEQ | tee /tmp/seq \ No newline at end of file +echo $SEQ | tee /tmp/seq