exec_git_command using exec_process_substitution()
This commit is contained in:
parent
4a8b76f815
commit
27086af023
27
git_helpers
27
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"
|
||||
}
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user