From c3a263ff97bcd31e96abbfed33d066f8d2778f58 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 31 Mar 2014 18:12:12 +0200 Subject: shell: support ":" separator Useful for tshark. --- shell | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/shell b/shell index a0ab1fb..5c1e28a 100755 --- a/shell +++ b/shell @@ -4,7 +4,7 @@ # Author: Peter Wu hidw() { - local hiddev arg bytes fillchar length + local hiddev arg bytes fillchar length oIFS hiddev=$1; shift bytes=() @@ -25,6 +25,11 @@ In this case, the message is padded with '0xff'. The data can also be interleaved with chars by starting an argument with a underscore (_). For example, "_foo" is equivalent to "66 6f 6f". +If only a single argument is given, the commands may be separated by +colons. The previous hidw example is equivalent to: + + hidw /dev/hidraw0 10:ff:81:ff.. + This function does not show replies, use the 'read-dev-usbmon' program instead. HELP @@ -36,6 +41,12 @@ HELP return 1 fi + # Support ":" as separator if there is only a single argument. This makes + # it easier to work with tshark output, and does not break "_:" arguments. + if [ $# -eq 1 ]; then + oIFS="$IFS"; IFS=:; set -- $*; IFS="$oIFS" + fi + for arg; do # clear the fill char, makes only sense as last argument fillchar= -- cgit v1.2.1