Skip to content

Commit f8f3561

Browse files
authored
Fix 'case' statements not being evaluated
1 parent 1d056a9 commit f8f3561

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

git-fmt-diff

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ cleanup () (
4848
)
4949

5050
debug () (
51-
[ "$3" != "--" ] && [ "$gf_debug" -eq 0 ] && return
52-
>&2 printf "[debug] %s @ %s:%d # " "$(basename "$0")" "$1" "$2"
53-
shift 2
51+
[ "$2" != "--" ] && [ "$gf_debug" -eq 0 ] && return
52+
>&2 printf "[debug] %s:%d # " "$(basename "$0")" "$1"
53+
shift 1
5454
>&2 echo "$@"
5555
)
56-
alias debug='debug "$FUNCNAME" "$LINENO"'
56+
alias debug='debug "$LINENO"'
5757

5858
pat_list_to_case () (
59-
sed 's/\s\+/|/g'
59+
sed 's/\s*,\s*/|/g'
6060
)
6161

6262
rm_list__push () (
@@ -102,17 +102,19 @@ _git_conf_get__ft_map () (
102102

103103
git config --get-regexp "$gc_prog_name"'\.map-' | while read -r line; do
104104
debug "line = $line"
105-
line="$(echo "$line" | awk -F'--' '{print $2}')"
105+
line="$(echo "$line" | awk -F'map-' '{print $2}')"
106106
ft="$(echo "$line" | cut -d' ' -f1)"
107107
ext="$(echo "$line" | cut -d' ' -f2- | pat_list_to_case)"
108108

109-
# shellcheck disable=SC2254
110-
case "$file" in
111-
$ext)
112-
echo "$ft"
113-
return
114-
;;
115-
esac
109+
if [ -n "$ext" ]; then
110+
# shellcheck disable=SC2254
111+
eval "case '$file' in
112+
$ext)
113+
echo '$ft'
114+
return
115+
;;
116+
esac"
117+
fi
116118
done
117119
)
118120

@@ -177,7 +179,7 @@ _git_conf_get__pager () (
177179
_git_conf_get__var () (
178180
debug "args =" "$@"
179181
# shellcheck disable=SC2086
180-
git config $conf --get "$@"
182+
git config --get "$@"
181183
)
182184

183185
git_conf_get () (
@@ -223,9 +225,9 @@ git_conf_get () (
223225
if [ -n "$list" ]; then
224226
list="$(echo "$list" | pat_list_to_case)"
225227
# shellcheck disable=SC2254
226-
case "$file" in
228+
eval "case '$file' in
227229
$list) val=1 ;;
228-
esac
230+
esac"
229231
fi
230232
fi
231233

0 commit comments

Comments
 (0)