From d80a02a2db597cfab665d2e9680c8eba029cac44 Mon Sep 17 00:00:00 2001 From: Jon Shaulis Date: Tue, 6 Sep 2016 12:23:14 -0400 Subject: [PATCH] Only trim first and last single quotes --- plexupdate.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index bc2a9a1..30dc87b 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -138,6 +138,18 @@ running() { fi } +trimQuotes() { + local __retvar=$1 + local __buffer=${!__retvar} + + # Remove leading single quote + __buffer=${__buffer#\'} + # Remove ending single quote + __buffer=${__buffer%\'} + + echo $__buffer +} + # Parse commandline ALLARGS=( "$@" ) optstring="acCdfFhlpqrSsuU -l config:,dldir:,email:,pass:,server:,saveconfig" @@ -170,11 +182,11 @@ do (-u) AUTOUPDATE_CL=yes;; (-U) IGNOREAUTOUPDATE=yes;; - (--config) shift; CONFIGFILE=$(echo "$1" | tr -d "'");; - (--dldir) shift; DOWNLOADDIR_CL=$(echo "$1" | tr -d "'");; - (--email) shift; EMAIL_CL=$(echo "$1" | tr -d "'");; - (--pass) shift; PASS_CL=$(echo "$1" | tr -d "'");; - (--server) shift; PLEXSERVER_CL=$(echo "$1" | tr -d "'");; + (--config) shift; CONFIGFILE="$1"; CONFIGFILE=$(trimQuotes CONFIGFILE);; + (--dldir) shift; DOWNLOADDIR_CL="$1"; DOWNLOADDIR_CL=$(trimQuotes DOWNLOADDIR_CL);; + (--email) shift; EMAIL_CL="$1"; EMAIL_CL=$(trimQuotes EMAIL_CL);; + (--pass) shift; PASS_CL="$1"; PASS_CL=$(trimQuotes PASS_CL);; + (--server) shift; PLEXSERVER_CL="$1"; PLEXSERVER_CL=$(trimQuotes PLEXSERVER_CL);; (--saveconfig) SAVECONFIG=yes;; (--) ;;