on xenial help sign in
Bring long options back
commit7302a62c6edeb1394e20a2ba3f002ee9e01eb148 authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 8 Sep 2014, 15:51 (12 years ago) parent28c53f9
1 file changed+19−16
run_on_device.sh+19−16
run_on_device.sh+19−16
@@ -25,11 +25,11 @@ usage() {
2525 echo "Script to setup a build environment for the shell and sync build and run it on the device"
2626 echo
2727 echo "OPTIONS:"
28− echo " -a The sudo password to use"
29− echo " -s Setup the build environment"
30− echo " -g Run with gdb"
31− echo " -p Enable a PIN lock screen when running"
32− echo " -k Enable a Keyboard lock screen when running"
28+ echo " -a, --password The sudo password to use"
29+ echo " -s, --setup Setup the build environment"
30+ echo " -g, --gdb Run with gdb"
31+ echo " -p, --pinlock Enable a PIN lock screen when running"
32+ echo " -k, --keylock Enable a Keyboard lock screen when running"
3333 echo
3434 echo "IMPORTANT:"
3535 echo " * Make sure to have networking setup on the device beforehand."
@@ -107,20 +107,23 @@ run() {
107107 exec_with_ssh "start unity8"
108108}
109109
110−while getopts "a:sgpkh" OPTION; do
111− case "$OPTION" in
112− a) PASSWORD=$OPTARG;;
113− s) SETUP=true;;
114− g) GDB=true;;
115− p) PINLOCK=true;;
116− k) KEYLOCK=true;;
117− h) usage;;
118− ?) echo;usage;;
110+set -- `getopt -n$0 -u -a --longoptions="password:,setup,gdb,pinlock,keylock,help" "a:sgpkh" "$@"`
111+
112+# FIXME: giving incorrect arguments does not call usage and exit
113+while [ $# -gt 0 ]
114+do
115+ case "$1" in
116+ -a|--password) PASSWORD=$2;;
117+ -s|--setup) SETUP=true;;
118+ -g|--gdb) GDB=true;;
119+ -p|--pinlock) PINLOCK=true;;
120+ -k|--keylock) KEYLOCK=true;;
121+ -h|--help) usage;;
122+ --) shift;break;;
119123 esac
124+ shift
120125done
121126
122−shift $((OPTIND - 1))
123−
124127if [ -z "${PASSWORD}" ]; then
125128 echo "ERROR: You need to provide a sudo password..."
126129 echo