From 27c43e8b8ab604e7bbf3b9d312ff755cf025cbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Sat, 25 May 2013 13:26:41 +0200 Subject: [PATCH] Improve a bit shell scripts portability. - Use /bin/sh: bash is not required here; - Avoid Perl regexp in grep(1): this is a GNU extension; - While here, make ReadNavigo.sh fail earlier if pn53x-tamashell fails at first invocation. Reported by: Ganael Laplanche --- examples/pn53x-tamashell-scripts/ReadMobib.sh | 2 +- examples/pn53x-tamashell-scripts/ReadNavigo.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/pn53x-tamashell-scripts/ReadMobib.sh b/examples/pn53x-tamashell-scripts/ReadMobib.sh index 24a3330..c4dd43c 100755 --- a/examples/pn53x-tamashell-scripts/ReadMobib.sh +++ b/examples/pn53x-tamashell-scripts/ReadMobib.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh cat << EOF | \ pn53x-tamashell |\ diff --git a/examples/pn53x-tamashell-scripts/ReadNavigo.sh b/examples/pn53x-tamashell-scripts/ReadNavigo.sh index 4a72600..13e6bf5 100755 --- a/examples/pn53x-tamashell-scripts/ReadNavigo.sh +++ b/examples/pn53x-tamashell-scripts/ReadNavigo.sh @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh ID=$(cat << EOF | \ pn53x-tamashell |\ grep -A1 "^Tx: 42 01 0b 3f 80" |\ - grep -o -P "(?<=Rx: 00 .. .. ).. .. .. .."|sed 's/ //g' + sed -e '1d' -e "s/^Rx: 00 .. .. \(.. .. .. ..\).*/\1/" -e 's/ //g' # Timeouts 3205000002 # ListTarget ModeB @@ -13,6 +13,11 @@ ID=$(cat << EOF | \ EOF ) +if [ -z "$ID" ]; then + echo "Error: I was not abble to read Navigo ID" >&2 + exit 1 +fi + cat << EOF | \ pn53x-tamashell |\ awk '\