diff options
author | Dan Horák <dan@danny.cz> | 2010-04-21 11:22:23 +0200 |
---|---|---|
committer | Dan Horák <dan@danny.cz> | 2010-04-21 11:22:23 +0200 |
commit | 08fe99f7203cb2e0bb44b93bd069460c7ff95401 (patch) | |
tree | bfc56ac30fb278eac600af733acd5d3e8bcfd4ba | |
parent | 2d7b5f8bcbfd2de0657062b0dfc0d78645f8f9cc (diff) | |
download | utils-08fe99f7203cb2e0bb44b93bd069460c7ff95401.tar.gz utils-08fe99f7203cb2e0bb44b93bd069460c7ff95401.tar.xz utils-08fe99f7203cb2e0bb44b93bd069460c7ff95401.zip |
split the comma separated list of devices when freeing them
-rw-r--r-- | device_cio_free | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/device_cio_free b/device_cio_free index b5f9514..5182263 100644 --- a/device_cio_free +++ b/device_cio_free @@ -35,24 +35,27 @@ usage() } # accepts single device, comma-separated lists and dash separated ranges and their combinations +# the comma separated list is split so we minimize the effect of unsuccessful freeing free_device() { - local DEV + local DEV DEV_LIST [ -z "$1" ] && return - DEV=$(echo "$1" | tr "A-Z" "a-z") - - [ $VERBOSE ] && echo "Freeing device(s) $DEV" - if ! echo "free $DEV" > $BLACKLIST 2> /dev/null ; then - echo "Error: can't free device(s) $DEV" - else - if [ -z $ALL_DEVICES ]; then - ALL_DEVICES="$DEV" + DEV_LIST=$(echo "$1" | tr "A-Z" "a-z" | sed 's/,/ /g') + + for DEV in $DEV_LIST; do + [ $VERBOSE ] && echo "Freeing device(s) $DEV" + if ! echo "free $DEV" > $BLACKLIST 2> /dev/null ; then + echo "Error: can't free device(s) $DEV" else - ALL_DEVICES="$ALL_DEVICES,$DEV" + if [ -z $ALL_DEVICES ]; then + ALL_DEVICES="$DEV" + else + ALL_DEVICES="$ALL_DEVICES,$DEV" + fi fi - fi + done } # wait until a device appears on the ccw bus @@ -196,7 +199,7 @@ while [ $# -gt 0 ]; do ;; -d|--device) shift - [ -n "$1" ] && DEVICE="$DEVICE $1" || usage + [ -n "$1" ] && DEVICE="$DEVICE,$1" || usage ;; *) echo "Error: unknown option $1" @@ -213,9 +216,7 @@ fi if [ "$DEVICE" ]; then [ $VERBOSE ] && echo "Freeing specific devices" - for DEV in $DEVICE; do - free_device $DEV - done + free_device $DEVICE wait_on_devices exit 0 fi |