From 96d115de0e7f7d2cc48d283f779b94ec5f93746d Mon Sep 17 00:00:00 2001 From: Alex Malinovich Date: Tue, 26 Jul 2016 15:18:46 -0700 Subject: [PATCH] Fix to allow combined command-line options Due to a feature/bug in getopt, calling plexupdate.sh with concatenated options (e.g. `plexupdate.sh -cq`), causes an error even though modern versions of getopt have support for that format. The culprit seems to be the "getopt compatibility mode". With these changes, a modern implementation of getopt will work correctly with more complex options, while old versions will continue to work as they currently do (requiring multiple options to be given independently e.g. `plexupdate.sh -c -q`) --- plexupdate.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 665cfc0..25659bd 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -165,7 +165,12 @@ usage() { # Parse commandline ALLARGS=( "$@" ) -set -- $(getopt acCdfhkopqruU: -- "$@") +optstring="acCdfhkopqruU" +getopt -T >/dev/null +if [ $? -eq 4 ]; then + optstring="-o $optstring" +fi +set -- $(getopt $optstring -- "$@") while true; do case "$1" in