jonas / tig

Text-mode interface for git
https://jonas.github.io/tig/
GNU General Public License v2.0
12.41k stars 607 forks source link

%(lineno) broken in custom bindings for the blame view #1209

Closed pspacek closed 2 years ago

pspacek commented 2 years ago

Version affected: 13bcb402230a3ff7e668966cda9e5d125711a4d4

No matter what I try the %(lineno) expansion for "blame" view custom binding always returns value "9".

Reproducer

Configuration:

bind blame e !/tmp/test.sh %(commit) %(file) %(lineno)

Script /tmp/test.sh:

#!/bin/bash
COMMIT="$1"
FILE="$2"
LINENO="$3"

echo $COMMIT
echo $FILE
echo $LINENO

Command:

tig blame src/ui.c

Now press e while standing on the first line of blame view.

test.sh output:

395611ebf13cbcebee1791b5c9d81ef2c6823475
src/ui.c
9

Huh?

I tried to move the cursor to a different line but number 9 stays there. Valgrind does not complain about uninitialized memory.

koutcher commented 2 years ago

Valgrind is a bit overkill here, a simple :!echo %(lineno) would have been enough to let Tig off the hook. test.sh is the one to blame here, you can't use LINENO for a variable name, see bash(1).

pspacek commented 2 years ago

Thank you very much - and my apologies! I did not suspect Bash builtin :facepalm: