From 27086af02389da1b6db9eb9e052e77fe0974daf6 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Sat, 4 Jun 2022 14:48:30 +0200 Subject: [PATCH] exec_git_command using exec_process_substitution() --- git_helpers | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/git_helpers b/git_helpers index 227673c..07990cf 100755 --- a/git_helpers +++ b/git_helpers @@ -9,6 +9,7 @@ # source ./log_helpers +source ./general_utils readonly GIT_SSL_NO_VERIFY=true readonly repository_already_up_to_date=2 @@ -16,30 +17,12 @@ readonly repository_already_up_to_date=2 # exec_git_command () { local func="${FUNCNAME[0]}" - log_debug "$func:${LINENO} exec-ing [$*]" + + local __git_result=$(exec_process_substitution $*) + log_debug "$func:${LINENO} result=$__git_result" - exec {fd}< <(eval "$@") - - # if [ "$*" = "git pull" ]; then - # else - # exec {fd}< <($@) - # fi - - local ps_pid=$! # remember pid of process substitution - - local git_result="" - while read t <&$fd; do - if ! [ -z "$t" ]; then - git_result="${git_result}$t" - fi - done - - exec {fd}>&- # close fd (i.e. process substitution) - wait $ps_pid # wait for the subshell to finish - - git_result=$(printf "$git_result" | tr '\n' ' ') - printf "%s\n" $git_result + printf '%s' "$__git_result" } #