summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim <elatllat@gmail.com>2020-09-01 16:18:04 +0300
committerDongjin Kim <tobetter@gmail.com>2020-10-13 07:28:34 +0300
commitf68611012348b640eaf9a4836d07c2b6bd492aa9 (patch)
treebb04467a66f5c0bcf4d746e71c226439cc189a64
parent99113eeaa71a5c524c752096190ec5ab28c3720d (diff)
downloadu-boot-f68611012348b640eaf9a4836d07c2b6bd492aa9.tar.xz
Update sd_fusing.sh
remove cd requirement, shellcheck
-rwxr-xr-xsd_fuse/sd_fusing.sh17
1 files changed, 10 insertions, 7 deletions
diff --git a/sd_fuse/sd_fusing.sh b/sd_fuse/sd_fusing.sh
index 451013f119..8698294127 100755
--- a/sd_fuse/sd_fusing.sh
+++ b/sd_fuse/sd_fusing.sh
@@ -7,17 +7,20 @@
#
abort() {
- echo $1
+ echo "$1"
exit 1
}
-[ -z $1 ] && abort "usage: $0 <your/memory/card/device>"
-[ -z ${UBOOT} ] && UBOOT=${PWD}/u-boot.bin
-[ ! -f ${UBOOT} ] && abort "error: ${UBOOT} is not exist"
+[ -z "$1" ] && abort "usage: $0 <your/memory/card/device>"
+[ -z "$UBOOT" ] && UBOOT="${PWD}/u-boot.bin"
+if [ ! -f "$UBOOT" ] ; then
+ UBOOT="$(echo "$0" | perl -pe 's/[^\/]*$//g')u-boot.bin"
+fi
+[ ! -f "$UBOOT" ] && abort "error: $UBOOT is not exist"
-sudo dd if=$UBOOT of=$1 conv=fsync,notrunc bs=512 seek=1
+sudo dd if="$UBOOT" of="$1" conv=fsync,notrunc bs=512 seek=1
sync
-sudo eject $1
-echo Finished.
+sudo eject "$1"
+echo "Finished."