summaryrefslogtreecommitdiffstats
path: root/init_functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-11-06 02:26:53 +0100
committerDave Reisner <dreisner@archlinux.org>2011-11-15 01:11:09 +0100
commit09bbcaf175be235874cceee0f0e75781ed100d02 (patch)
treed1f46bea665e40f09fe340e5bc05fdf068beac94 /init_functions
parentf3fc3912c333e1e722b8120930cdfbecf642a284 (diff)
downloadmkinitcpio-09bbcaf175be235874cceee0f0e75781ed100d02.tar.gz
mkinitcpio-09bbcaf175be235874cceee0f0e75781ed100d02.tar.xz
init_functions: refactor poll_device
Beyond stylistic cleanup, add a conditional to ensure that we don't show the 'waiting for device' message if it already exists. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'init_functions')
-rw-r--r--init_functions23
1 files changed, 12 insertions, 11 deletions
diff --git a/init_functions b/init_functions
index e026929..7dd0968 100644
--- a/init_functions
+++ b/init_functions
@@ -8,20 +8,21 @@ err () {
}
poll_device() {
- device="$1"
- if [ "$2" -ge 0 ]; then
- seconds="$2"
- else
- seconds=5
- fi
- if [ "${udevd_running}" -eq 1 ]; then
- msg "Waiting ${seconds} seconds for device ${device} ..."
- while [ ! -b "${device}" -a ${seconds} -gt 0 ]; do
+ local device=$1 seconds=${2//[!0-9]}
+
+ [ -z "$seconds" ] && seconds=5
+
+ [ -b "$device" ] && return 0
+
+ if [ "$udevd_running" -eq 1 ]; then
+ msg "Waiting $seconds seconds for device $device ..."
+ while [ ! -b "$device" -a "$seconds" -gt 0 ]; do
sleep 1
- seconds=$((${seconds}-1))
+ seconds=$(( $seconds - 1 ))
done
fi
- [ -b "${device}" ]
+
+ [ -b "$device" ]
}
launch_interactive_shell() {