diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-03-31 18:12:12 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-03-31 18:12:12 +0200 |
commit | c3a263ff97bcd31e96abbfed33d066f8d2778f58 (patch) | |
tree | 5c16adba789999eaf4819674a1bf2ce9059134ee | |
parent | fe7edfe3a3d2e5fb47ea8349e30ebcd3190fd18e (diff) | |
download | ltunify-c3a263ff97bcd31e96abbfed33d066f8d2778f58.tar.gz |
shell: support ":" separator
Useful for tshark.
-rwxr-xr-x | shell | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -4,7 +4,7 @@ # Author: Peter Wu <lekensteyn@gmail.com> 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= |