From 20e6455559ec73aeb599faa4b1a0837d36a238ce Mon Sep 17 00:00:00 2001 From: Nicolai Skogheim Date: Tue, 28 Jul 2015 06:13:59 +0200 Subject: [PATCH 1/3] Pass --import-functions if required This patch is the reason for this commit: https://lists.freebsd.org/pipermail/svn-ports-all/2014-September/075090.html --- bin/git-effort | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/git-effort b/bin/git-effort index 278689b..58c57e4 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -193,9 +193,18 @@ export -f dates export above export log_args + +bash_params= +# If bash exits sucessfully with --import-functions, +# then we need to pass it (FreeBSD probably) +bash --import-functions -c ":" 1>/dev/null 2>&1 +if [ $? -eq 0 ] ; then + bash_params="--import-functions" +fi + heading # send files to effort -printf "%s\0" "${files[@]}" | xargs -0 -n 1 -P 4 -I % bash -c "effort \"%\"" | tee $tmp +printf "%s\0" "${files[@]}" | xargs -0 -n 1 -P 4 -I % bash $bash_params -c "effort \"%\"" | tee $tmp # if more than one file, sort and print test "$(wc -l $tmp | awk '{print $1}')" -gt 1 && sort_effort From cdb773c06532b9178df9a0d758772cd3968753c1 Mon Sep 17 00:00:00 2001 From: Nicolai Skogheim Date: Tue, 28 Jul 2015 20:41:53 +0200 Subject: [PATCH 2/3] Fix error on FreeBSD with process substitution --- bin/git-effort | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-effort b/bin/git-effort index 58c57e4..5325b26 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -35,7 +35,7 @@ show_cursor_and_cleanup() { # active_days() { - uniq <(echo "$1") | wc -l + uniq <<<$(echo "$1") | wc -l } # From 1956d385bd10fa116c3ec5158b96d74e993d7322 Mon Sep 17 00:00:00 2001 From: Nicolai Skogheim Date: Tue, 28 Jul 2015 21:00:27 +0200 Subject: [PATCH 3/3] Guard against 'seq 0' Most implementations of seq yields no output for 'seq 0', but some yields '1(newline)0'. --- bin/git-effort | 54 +++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/bin/git-effort b/bin/git-effort index 5325b26..5a102f5 100755 --- a/bin/git-effort +++ b/bin/git-effort @@ -119,33 +119,37 @@ above_index=0 has_above=false next_is_above=false num_files=0 -for i in `seq ${#@}` -do - cur="${!i}" - if "$next_is_above" ; then - above="$cur" - next_is_above=false - continue - fi +# Some implementations of `seq` gives "1\n0" for seq 0 +if [ $# -gt 0 ] ; then + for i in `seq ${#@}` + do + cur="${!i}" - case "$cur" in - --above) - if "$has_above" ; then - echo "error: --above can only be specified one time" 1>&2 - exit 1 - fi - next_is_above=true - has_above=true - above_index=$(( i - 1 )) - ;; - --*) - ;; - *) - num_files=$(( num_files + 1 )) - ;; - esac -done + if "$next_is_above" ; then + above="$cur" + next_is_above=false + continue + fi + + case "$cur" in + --above) + if "$has_above" ; then + echo "error: --above can only be specified one time" 1>&2 + exit 1 + fi + next_is_above=true + has_above=true + above_index=$(( i - 1 )) + ;; + --*) + ;; + *) + num_files=$(( num_files + 1 )) + ;; + esac + done +fi # Exit if above-value is not an int if [ -z "${above##*[!0-9]*}" ] ; then