Skip to content

Commit fedd5c7

Browse files
bk2204gitster
authored andcommitted
vimdiff: make script and tests work with zsh
When we process the $LAYOUT variable through sed, the result will end with the character "#". We then split it at the shell using IFS so that we can process it a character at a time. POSIX specifies that only "IFS white space shall be ignored at the beginning and end of the input". The hash mark is not a white space character, so it is not ignored at the beginning and end of the input. POSIX then specifies that "[e]ach occurrence in the input of an IFS character that is not IFS white space, along with any adjacent IFS white space, shall delimit a field, as described previously." Thus, the final hash mark delimits a field, and the final field is the empty string. zsh implements this behavior strictly in compliance with POSIX (and differently from most other shells), such that we end up with a trailing empty field. We don't want this empty field and processing it in the normal way causes us to fail to parse properly and fail the tests with "ERROR" entries, so let's just ignore it instead. This is the behavior of bash and dash anyway and what was clearly intended, so this is a reasonable thing to do. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 058b8dc commit fedd5c7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

mergetools/vimdiff

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ gen_cmd_aux () {
7272
nested=0
7373
nested_min=100
7474

75-
7675
# Step 1:
7776
#
7877
# Increase/decrease "start"/"end" indices respectively to get rid of
@@ -87,7 +86,7 @@ gen_cmd_aux () {
8786
IFS=#
8887
for c in $(echo "$LAYOUT" | sed 's:.:&#:g')
8988
do
90-
if test "$c" = " "
89+
if test -z "$c" || test "$c" = " "
9190
then
9291
continue
9392
fi

0 commit comments

Comments
 (0)