From 759c9fa4a82c1480975096e83709f5e632eeb11b Mon Sep 17 00:00:00 2001 From: christopheNan Date: Tue, 23 May 2023 21:44:14 +0200 Subject: [PATCH] syntaxe sh et non bash. Merci @mdk --- .scripts/fuzzy_diff | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.scripts/fuzzy_diff b/.scripts/fuzzy_diff index 76695b0c..30251a64 100755 --- a/.scripts/fuzzy_diff +++ b/.scripts/fuzzy_diff @@ -10,8 +10,8 @@ _usage() { } LAUNCH_EDIT=1 -if [[ $# -eq 2 ]]; then - if [[ $1 -eq "-n" ]] || [[ $1 -eq "--no-edit" ]]; then +if [ $# -eq 2 ]; then + if [ "$1" -eq "-n" ] || [ "$1" -eq "--no-edit" ]; then LAUNCH_EDIT=0 else _usage @@ -19,11 +19,11 @@ if [[ $# -eq 2 ]]; then shift fi -if [[ $# -ne 1 ]]; then +if [ $# -ne 1 ]; then _usage fi -if [[ ! -f $1 ]]; then +if [ ! -f "$1" ]; then echo "$1: file not found" _usage fi @@ -34,7 +34,13 @@ trap 'rm --force --recursive "${TMP_DIR}"' EXIT PO_EDITOR=poedit -DIFFTOOL=$(git config diff.tool) +DIFFTOOL=$(which $(git config diff.tool)) + +if [ ! -x "$DIFFTOOL" ]; then + echo "git diff.tool seems not configured" + _usage +fi + PO_FILE=$1 # search for revs where fuzzy was added or suppressed @@ -43,7 +49,7 @@ FUZZY_REVS=$(git log --oneline -S '#, fuzzy' ${PO_FILE} | \ grep -i 'merge' | \ awk '{ print $1 }') -if [[ ${LAUNCH_EDIT} -eq 1 ]]; then +if [ ${LAUNCH_EDIT} -eq 1 ]; then ${PO_EDITOR} "${PO_FILE}" 2>/dev/null & fi