From c7024b410857b8f1cc727b5eae30fb79a11c5aff Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Tue, 22 May 2018 15:33:52 +0000 Subject: [PATCH] move promote_pipe_return to core functions this is too useful to leave down in the version control library; it turns the Nth pipe status into the current return value, allowing simpler and more readable checking of status. abstracted from version control library into core functions file. also dropping the two test files for checkin. --- scripts/core/functions.sh | 10 ++++++++++ .../bogus_file_tests_new_checkin-second_one.txt | 1 - scripts/rev_control/bogus_file_tests_new_checkin.txt | 1 - scripts/rev_control/version_control.sh | 8 ++++---- 4 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 scripts/rev_control/bogus_file_tests_new_checkin-second_one.txt delete mode 100644 scripts/rev_control/bogus_file_tests_new_checkin.txt diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index d1b9311e..a8e00f22 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -40,15 +40,25 @@ if [ -z "$skip_all" ]; then cd "$1" } + # returns true if the variable is an array. function is_array() { [[ "$(declare -p $1)" =~ "declare -a" ]] } + # returns true if the name provided is a defined alias. function is_alias() { alias $1 &>/dev/null return $? } + # makes the status of pipe number N (passed as first parameter) into the + # main return value (i.e., the value for $?). this is super handy to avoid + # repeating the awkward looking code below in multiple places. + function promote_pipe_return() + { + ( exit ${PIPESTATUS[$1]} ) + } + ############## # displays the value of a variable in bash friendly format. diff --git a/scripts/rev_control/bogus_file_tests_new_checkin-second_one.txt b/scripts/rev_control/bogus_file_tests_new_checkin-second_one.txt deleted file mode 100644 index 9a841051..00000000 --- a/scripts/rev_control/bogus_file_tests_new_checkin-second_one.txt +++ /dev/null @@ -1 +0,0 @@ -testing a file added diff diff --git a/scripts/rev_control/bogus_file_tests_new_checkin.txt b/scripts/rev_control/bogus_file_tests_new_checkin.txt deleted file mode 100644 index 9a841051..00000000 --- a/scripts/rev_control/bogus_file_tests_new_checkin.txt +++ /dev/null @@ -1 +0,0 @@ -testing a file added diff diff --git a/scripts/rev_control/version_control.sh b/scripts/rev_control/version_control.sh index e0102f61..fad41578 100644 --- a/scripts/rev_control/version_control.sh +++ b/scripts/rev_control/version_control.sh @@ -45,10 +45,10 @@ fi #hmmm: move this to core # this makes the status of pipe N into the main return value. -function promote_pipe_return() -{ - ( exit ${PIPESTATUS[$1]} ) -} +#function promote_pipe_return() +#{ +# ( exit ${PIPESTATUS[$1]} ) +#} ############## -- 2.34.1