Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <chris@tinyhost.de>
  • Loading branch information
SmithChart committed Nov 20, 2018
commit 5eb7ae6a194ec1b5f13d6e94a493b42e883af6dd
6 changes: 5 additions & 1 deletion telemetry-toolkit/telem-seq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
echo $SEQ | tee /tmp/seq