From dcdb6b45a32bab004279dbda4a1a985fc751bac7 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Tue, 15 Feb 2022 14:00:38 +0100 Subject: [PATCH] Enhanced exep() incl api help New helper function escpath() incl api help --- sequencer/sequencer.sh | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/sequencer/sequencer.sh b/sequencer/sequencer.sh index ce33f4f..84c14db 100755 --- a/sequencer/sequencer.sh +++ b/sequencer/sequencer.sh @@ -7,9 +7,9 @@ ## Version information -VERSION_REV=14 +VERSION_REV=15 VERSION_MAJOR=0 -VERSION_MINOR=2 +VERSION_MINOR=0 ## Start of generic script part @@ -144,13 +144,23 @@ cat < \\'out put.log\\' + exep echo hello world \\> out\\\\ put.log + exep "echo hello world > 'out put.log'" + exep "echo hello world > out\\ put.log" Important: - - Shell commands cd, read, ... won't work because COMMANDLINE is started in a new shell. + - Shell commands cd, read, ... won't work because [COMMAND STRING(s)] is started in a new shell. - All apostrophes need to be esacped since the command line is given as string. +USAGE_API +echo -e "${GREEN} escpath ${NC}" +cat < [TEMPLATE]${NC}" cat < [DESCRIPTION] # DESCRIPTION : Optional text for error endCheckEmpty() { @@ -1101,30 +1116,29 @@ showVersion() { } exe() { - local arr=("$@") if [ $DRY -ne 0 ] ; then echo -n "--" fi if [ $DRY -ne 0 ] || [ $VERBOSE -eq 1 ] ; then - (set -x; : "${arr[@]}") + (set -x; : "$@") fi if [ $DRY -eq 0 ] ; then - "${arr[@]}" + "$@" fi } # Handle dry run and verbose output for commands containing pipe and/or redirects -# exep +# exep exep() { if [ $DRY -ne 0 ] ; then - echo "--++ : $1" + echo "--++ : $*" elif [ $VERBOSE -eq 1 ] ; then - echo "++ : $1" + echo "++ : $*" fi if [ $DRY -eq 0 ] ; then - bash -c "$1" + bash -c "$*" fi }