Skip to content

Commit f686110

Browse files
Dmoletobetter
authored andcommitted
Update sd_fusing.sh
remove cd requirement, shellcheck
1 parent 99113ee commit f686110

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

sd_fuse/sd_fusing.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
#
88

99
abort() {
10-
echo $1
10+
echo "$1"
1111
exit 1
1212
}
1313

14-
[ -z $1 ] && abort "usage: $0 <your/memory/card/device>"
15-
[ -z ${UBOOT} ] && UBOOT=${PWD}/u-boot.bin
16-
[ ! -f ${UBOOT} ] && abort "error: ${UBOOT} is not exist"
14+
[ -z "$1" ] && abort "usage: $0 <your/memory/card/device>"
15+
[ -z "$UBOOT" ] && UBOOT="${PWD}/u-boot.bin"
16+
if [ ! -f "$UBOOT" ] ; then
17+
UBOOT="$(echo "$0" | perl -pe 's/[^\/]*$//g')u-boot.bin"
18+
fi
19+
[ ! -f "$UBOOT" ] && abort "error: $UBOOT is not exist"
1720

18-
sudo dd if=$UBOOT of=$1 conv=fsync,notrunc bs=512 seek=1
21+
sudo dd if="$UBOOT" of="$1" conv=fsync,notrunc bs=512 seek=1
1922

2023
sync
2124

22-
sudo eject $1
23-
echo Finished.
25+
sudo eject "$1"
26+
echo "Finished."

0 commit comments

Comments
 (0)