configure: sanitize for shellcheck

Signed-off-by: Anthony Romano <anthony.romano@coreos.com>
This commit is contained in:
Anthony Romano
2017-07-18 21:47:29 -07:00
committed by NIIBE Yutaka
parent 3270740631
commit db45e62ebe

39
src/configure vendored
View File

@@ -36,7 +36,6 @@ fi
help=no help=no
vidpid=none vidpid=none
target=FST_01 target=FST_01
verbose=no
with_dfu=default with_dfu=default
debug=no debug=no
sys1_compat=yes sys1_compat=yes
@@ -48,28 +47,26 @@ factory_reset=no
# Revision number # Revision number
if test -e ../.git; then if test -e ../.git; then
if type git >/dev/null 2>&1; then if type git >/dev/null 2>&1; then
REVISION=`git describe --dirty="-modified"` REVISION=$(git describe --dirty="-modified")
else else
# echo 'No git available, please install git' # echo 'No git available, please install git'
GIT_REVISION=$(sed -e 's/^\(.......\).*$/g\1/' ../.git/$(sed -e 's/^ref: //' ../.git/HEAD)) GIT_REVISION=$(sed -e 's/^\(.......\).*$/g\1/' "../.git/$(sed -e 's/^ref: //' ../.git/HEAD)")
REVISION=`cat ../VERSION`-$GIT_REVISION REVISION=$(cat ../VERSION)-$GIT_REVISION
fi fi
else else
REVISION=`cat ../VERSION` REVISION=$(cat ../VERSION)
fi fi
# Process each option # Process each option
for option; do for option; do
case $option in case $option in
*=*) optarg=`expr "X$option" : '[^=]*=\(.*\)'` ;; *=*) optarg=$(expr "X$option" : '[^=]*=\(.*\)') ;;
*) optarg=yes ;; *) optarg=yes ;;
esac esac
case $option in case $option in
-h | --help) -h | --help)
help=yes ;; help=yes ;;
-v | --verbose)
verbose=yes ;;
--vidpid=*) --vidpid=*)
vidpid=$optarg ;; vidpid=$optarg ;;
--target=*) --target=*)
@@ -155,9 +152,9 @@ if test "$vidpid" = "none"; then
exit 1 exit 1
fi fi
BOARD_HEADER_FILE=board-`echo $target | tr '_[:upper:]' '-[:lower:]'`.h BOARD_HEADER_FILE=board-$(echo $target | tr '_[:upper:]' '-[:lower:]').h
echo Header file is: $BOARD_HEADER_FILE echo "Header file is: $BOARD_HEADER_FILE"
ln -sf ../chopstx/board/$BOARD_HEADER_FILE board.h ln -sf "../chopstx/board/$BOARD_HEADER_FILE" board.h
# Flash page size in byte # Flash page size in byte
FLASH_PAGE_SIZE=1024 FLASH_PAGE_SIZE=1024
@@ -211,7 +208,7 @@ if test "$with_dfu" = "yes"; then
fi fi
echo "Configured for DFU" echo "Configured for DFU"
ORIGIN=0x08003000 ORIGIN=0x08003000
FLASH_SIZE=`expr $FLASH_SIZE - 12` FLASH_SIZE=$((FLASH_SIZE - 12))
DFU_DEFINE="#define DFU_SUPPORT 1" DFU_DEFINE="#define DFU_SUPPORT 1"
HEXOUTPUT_MAKE_OPTION="ENABLE_OUTPUT_HEX=yes" HEXOUTPUT_MAKE_OPTION="ENABLE_OUTPUT_HEX=yes"
else else
@@ -272,7 +269,7 @@ else
fi fi
### !!! Replace following string of "FSIJ" to yours !!! #### ### !!! Replace following string of "FSIJ" to yours !!! ####
SERIALNO="FSIJ-`cat ../VERSION | sed -e 's%^[^/]*/%%'`-" SERIALNO="FSIJ-$(sed -e 's%^[^/]*/%%' <../VERSION)-"
SERIALNO_STR_LEN_DEFINE="#define SERIALNO_STR_LEN ${#SERIALNO}" SERIALNO_STR_LEN_DEFINE="#define SERIALNO_STR_LEN ${#SERIALNO}"
@@ -292,8 +289,8 @@ else
fi fi
output_vid_pid_version () { output_vid_pid_version () {
echo $VIDPID | sed -n -e "s%^\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\):\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)$% 0x\2, 0x\1, /* idVendor */\\${nl} 0x\4, 0x\3, /* idProduct */%p" echo "$VIDPID" | sed -n -e "s%^\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\):\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)$% 0x\2, 0x\1, /* idVendor */\\${nl} 0x\4, 0x\3, /* idProduct */%p"
echo $VERSION | sed -n -e "s%^\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)$% 0x\2, 0x\1, /* bcdDevice */%p" echo "$VERSION" | sed -n -e "s%^\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)$% 0x\2, 0x\1, /* bcdDevice */%p"
} }
output_vendor_product_serial_strings () { output_vendor_product_serial_strings () {
@@ -303,14 +300,14 @@ output_vendor_product_serial_strings () {
echo " ${#VENDOR}*2+2, /* bLength */" echo " ${#VENDOR}*2+2, /* bLength */"
echo " STRING_DESCRIPTOR, /* bDescriptorType */" echo " STRING_DESCRIPTOR, /* bDescriptorType */"
echo " /* Manufacturer: \"$VENDOR\" */" echo " /* Manufacturer: \"$VENDOR\" */"
echo $VENDOR | sed -e "s/\(........\)/\1\\${nl}/g" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "/^ ./s/ $//p" echo "$VENDOR" | sed -e "s/\(........\)/\1\\${nl}/g" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "/^ ./s/ $//p"
echo '};' echo '};'
echo echo
echo "static const uint8_t ${prefix}string_product[] = {" echo "static const uint8_t ${prefix}string_product[] = {"
echo " ${#PRODUCT}*2+2, /* bLength */" echo " ${#PRODUCT}*2+2, /* bLength */"
echo " STRING_DESCRIPTOR, /* bDescriptorType */" echo " STRING_DESCRIPTOR, /* bDescriptorType */"
echo " /* Product name: \"$PRODUCT\" */" echo " /* Product name: \"$PRODUCT\" */"
echo $PRODUCT | sed -e "s/\(........\)/\1\\${nl}/g" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "/^ ./s/ $//p" echo "$PRODUCT" | sed -e "s/\(........\)/\1\\${nl}/g" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "/^ ./s/ $//p"
echo '};' echo '};'
if test -n "$prefix"; then if test -n "$prefix"; then
@@ -319,7 +316,7 @@ output_vendor_product_serial_strings () {
echo " ${#SERIALNO}*2+2+16, /* bLength */" echo " ${#SERIALNO}*2+2+16, /* bLength */"
echo " STRING_DESCRIPTOR, /* bDescriptorType */" echo " STRING_DESCRIPTOR, /* bDescriptorType */"
echo " /* Serial number: \"$SERIALNO\" */" echo " /* Serial number: \"$SERIALNO\" */"
echo $SERIALNO | sed -e "s/\(........\)/\1\\${nl}/g" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "/^ ./s/ $//p" echo "$SERIALNO" | sed -e "s/\(........\)/\1\\${nl}/g" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "/^ ./s/ $//p"
echo " 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff," echo " 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,"
echo " 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff," echo " 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,"
echo '};' echo '};'
@@ -329,7 +326,7 @@ output_vendor_product_serial_strings () {
echo " ${#REVISION}*2+2, /* bLength */" echo " ${#REVISION}*2+2, /* bLength */"
echo " STRING_DESCRIPTOR, /* bDescriptorType */" echo " STRING_DESCRIPTOR, /* bDescriptorType */"
echo " /* revision detail: \"$REVISION\" */" echo " /* revision detail: \"$REVISION\" */"
echo $REVISION | sed -e "s/\(........\)/\1\\${nl}/g" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "/^ ./s/ $//p" echo "$REVISION" | sed -e "s/\(........\)/\1\\${nl}/g" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "/^ ./s/ $//p"
echo '};' echo '};'
echo echo
echo "static const uint8_t ${prefix}config_options[] = {" echo "static const uint8_t ${prefix}config_options[] = {"
@@ -342,8 +339,8 @@ output_vendor_product_serial_strings () {
fi fi
} }
if !(IFS=" " if ! (IFS=" "
while read VIDPID VERSION PRODUCT VENDOR; do while read -r VIDPID VERSION PRODUCT VENDOR; do
if test "$vidpid" = "$VIDPID"; then if test "$vidpid" = "$VIDPID"; then
output_vid_pid_version > usb-vid-pid-ver.c.inc output_vid_pid_version > usb-vid-pid-ver.c.inc
output_vendor_product_serial_strings gnuk_ >usb-strings.c.inc output_vendor_product_serial_strings gnuk_ >usb-strings.c.inc