From 250cb64e45e18fde96dc1c2b42198ad5355c8c5a Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Fri, 20 Sep 2019 12:10:51 +0200 Subject: [PATCH] TT#65907 Remove unnecessary subshell calls in helper build_config It gives ~0.5 second better 'ngcpcfg apply' time. Change-Id: Ib8d331b9b057708cc34106b82e05128a8019a44e --- helper/build_config | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/helper/build_config b/helper/build_config index 869f9f67..08da06e9 100755 --- a/helper/build_config +++ b/helper/build_config @@ -46,6 +46,7 @@ if [ -n "${OUTPUT_DIRECTORY:-}" ] ; then else export output_file fi +output_file_dirname="$(dirname "${output_file}")" # like /etc/mysql # ensure we don't try to generate a file where a directory with same name exists already if [ -d "${output_file}" ] ; then @@ -57,15 +58,15 @@ fi if [ -r "${NGCPCTL_MAIN}/templates/${output_file}.prebuild" ] ; then log_info "Executing prebuild for ${output_file}" bash "${NGCPCTL_MAIN}/templates/${output_file}.prebuild" -elif [ -r "${NGCPCTL_MAIN}/templates/$(dirname "${output_file}")/ngcpcfg.prebuild" ] ; then +elif [ -r "${NGCPCTL_MAIN}/templates/${output_file_dirname}/ngcpcfg.prebuild" ] ; then log_info "Executing prebuild for ${output_file}" - bash "${NGCPCTL_MAIN}/templates/$(dirname "${output_file}")/ngcpcfg.prebuild" + bash "${NGCPCTL_MAIN}/templates/${output_file_dirname}/ngcpcfg.prebuild" fi # if output directory does not exist yet, create it -if ! [ -d "$(dirname "${output_file}")" ] ; then +if ! [ -d "${output_file_dirname}" ] ; then umask 0022 # directory permissions should be '755' - mkdir -p "$(dirname "${output_file}")" + mkdir -p "${output_file_dirname}" fi # assume safe defaults @@ -144,9 +145,9 @@ fi if [ -r "${NGCPCTL_MAIN}/templates/${output_file}.postbuild" ] ; then log_info "Executing postbuild for ${output_file}" bash "${NGCPCTL_MAIN}/templates/${output_file}.postbuild" -elif [ -r "${NGCPCTL_MAIN}/templates/$(dirname "${output_file}")/ngcpcfg.postbuild" ] ; then +elif [ -r "${NGCPCTL_MAIN}/templates/${output_file_dirname}/ngcpcfg.postbuild" ] ; then log_info "Executing postbuild for ${output_file}" - bash "${NGCPCTL_MAIN}/templates/$(dirname "${output_file}")/ngcpcfg.postbuild" + bash "${NGCPCTL_MAIN}/templates/${output_file_dirname}/ngcpcfg.postbuild" fi exit $RC