Stuart Pook wrote:
> I have the "expr: syntax error" as well
expr doesn't appear in the codebase as at debian/4.0_alpha30-1.
This appears to be the commit that fixes it.
The new version could probably use SUS parameter expansion:
$ busybox ash
BusyBox v1.18.4 (Ubuntu 1:1.18.4-2ubuntu2) built-in shell (ash)
Enter 'help' for a list of built-in commands.
$ DEVICE=/dev/sda1p1
$ DEVICE=${DEVICE#/dev/} DEVICE=${DEVICE%%[0-9]*}
$ echo "$DEVICE"
sda
commit 3ce6f9e8fe33cfdda99b0bffbb3fa69063014047
Author: Daniel Baumann <mail@daniel-baumann.ch>
Date: Mon May 6 20:42:55 2013 +0200
Replacing expr usage in initscript for eject boot media with something less error prone.
diff --git a/bin/boot-init.sh b/bin/boot-init.sh
index 83f37bc..3027d28 100755
--- a/bin/boot-init.sh
+++ b/bin/boot-init.sh
@@ -80,10 +80,17 @@ get_boot_device()
device_is_USB_flash_drive()
{
# remove leading "/dev/" and all trailing numbers from input
- DEVICE=$(expr substr ${1} 6 3)
+ DEVICE=$(echo ${1} | sed -e 's|/dev/||' -e 's|[0-9].*$||')
# check that device starts with "sd"
- [ "$(expr substr ${DEVICE} 1 2)" != "sd" ] && return 1
+ case "${DEVICE}" in
+ sd*)
+ ;;
+
+ *)
+ return 1
+ ;;
+ esac
# check that the device is an USB device
if readlink /sys/block/${DEVICE} | grep -q usb
Attachment:
signature.asc
Description: Digital signature