From 7a61dcd718bf879051c3cf7326d2daa7554d296b Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Thu, 4 Jun 2020 15:19:17 +0200 Subject: [PATCH] Refining initSeqConfig function Option to choose if empty config should be created (Is not by default) --- sequencer/sequencer.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/sequencer/sequencer.sh b/sequencer/sequencer.sh index e11b7f5..cacf324 100755 --- a/sequencer/sequencer.sh +++ b/sequencer/sequencer.sh @@ -7,9 +7,9 @@ ## Version information -VERSION_REV=10 +VERSION_REV=11 VERSION_MAJOR=0 -VERSION_MINOR=2 +VERSION_MINOR=0 ## Start of generic script part @@ -100,11 +100,13 @@ helpApi() { echo " Create a configuration file in $SEQ_CONFIG_HOME/ and source it if already existent." echo " [OPTION]" echo " -t : Source config also if created from template" + echo " -e : Create empty configuration if no template is found" echo " Returns" echo " 0 : sourced configuration or" echo " (-t) : created and sourced configuration from template" echo " 1 : created configuration from template but not sourced" echo " 2 : created empty configuration" + echo " 3 : No configuration created" echo echo " addConf [SOURCE TYPE] " echo " Trying to write or append text or a file () to a destination file." @@ -285,19 +287,26 @@ endReturn() { # Source it if already existent # [OPTION] # -t : Source config also if created from template +# -e : Create empty configuration if no template is found # Return # 0 : Sourced configuration or # (-t) : created and sourced configuration from template # 1 : Created configuration from template but not sourced # 2 : Created empty configuration +# 3 : No configuration created initSeqConfig() { local sourceAlways=0 + local createEmpty=0 for arg in "$@" ; do case "$1" in -t) sourceAlways=1 shift ;; + -e) + createEmpty=1 + shift + ;; esac done @@ -347,13 +356,18 @@ initSeqConfig() { return 0 fi else - echo " [W] Seq configuration template empty" + echo " [W] Seq configuration template not found" fi - # Create empty config file - echo " [W] Created empty configuration file $configLoc" - exe touch "$configLoc" - return 2 + if [ $createEmpty -ne 0 ] ; then + # Create empty config file + echo " [W] Created empty configuration file $configLoc" + exe touch "$configLoc" + return 2 + fi + + echoerr " [E] No seq configuration created" + return 3 } # addConf [FILE_MODE]