Signed-off-by: John Keeping <john@xxxxxxxxxxxxx> --- git-mergetool--lib.sh | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index b6ed2fa..b44a2c8 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -22,6 +22,7 @@ is_available () { show_tool_names () { condition=${1:-true} per_line_prefix=${2:-} preamble=${3:-} + not_found_msg=${4:-} shown_any= ( cd "$MERGE_TOOLS_DIR" && ls ) | { @@ -32,13 +33,19 @@ show_tool_names () { then if test -n "$preamble" then - echo "$preamble" + printf "%s\n" "$preamble" preamble= fi shown_any=yes printf "%s%s\n" "$per_line_prefix" "$toolname" fi done + + if test -n "$preamble" && test -n "$not_found_msg" + then + printf "%s\n" "$not_found_msg" + fi + test -n "$shown_any" } } @@ -242,30 +249,27 @@ list_merge_tool_candidates () { show_tool_help () { tool_opt="'git ${TOOL_MODE}tool --tool-<tool>'" - tab=' ' av_shown= unav_shown= + tab=' ' + LF=' +' + any_shown=no cmd_name=${TOOL_MODE}tool - if show_tool_names 'mode_ok && is_available' "$tab$tab" \ - "$tool_opt may be set to one of the following:" - then - av_shown=yes - else - echo "No suitable tool for 'git $cmd_name --tool=<tool>' found." - av_shown=no - fi + show_tool_names 'mode_ok && is_available' "$tab$tab" \ + "$tool_opt may be set to one of the following:" \ + "No suitable tool for 'git $cmd_name --tool=<tool>' found." && + any_shown=yes - if show_tool_names 'mode_ok && ! is_available' "$tab$tab" \ - "The following tools are valid, but not currently available:" - then - unav_shown=yes - fi + show_tool_names 'mode_ok && ! is_available' "$tab$tab" \ + "${LF}The following tools are valid, but not currently available:" && + any_shown=yes - case ",$av_shown,$unav_shown," in - *,yes,*) + if test "$any_shown" = yes + then echo echo "Some of the tools listed above only work in a windowed" echo "environment. If run in a terminal-only session, they will fail." - esac + fi exit 0 } -- 1.8.1.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html