Junio C Hamano <gitster@xxxxxxxxx> writes: > Shouldn't this "is it absolute" check with "$cmd" also check if $cmd > has either forward or backward slash in it? > > Checking the use of _which with fixed arguments, it is used to spawn > git, gitk, nice, sh; and _which finding where they appear on the > search path does sound sane. But _which does not seem to have the "if > given a command with directory separator, the search path does not > matter. The caller means it is relative to the $cwd" logic at all, > so it seems it is the callers responsibility to make sure it does > not pass things like ".git/hooks/pre-commit" to it. In other words, something along this line may go in the right direction (I no longer speak Tcl, and this is done with manual in one hand, while typing with the other hand). git-gui.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git c/git-gui.sh w/git-gui.sh index 8bc8892c40..45d8f48b39 100755 --- c/git-gui/git-gui.sh +++ w/git-gui/git-gui.sh @@ -119,11 +119,15 @@ proc sanitize_command_line {command_line from_index} { while {$i < [llength $command_line]} { set cmd [lindex $command_line $i] if {[file pathtype $cmd] ne "absolute"} { - set fullpath [_which $cmd] - if {$fullpath eq ""} { - throw {NOT-FOUND} "$cmd not found in PATH" + if {1 < [llength [file split $cmd]]]} { + set cmdpath [_which $cmd] + if {$cmdpath eq ""} { + throw {NOT-FOUND} "$cmd not found in PATH" + } + } else { + set cmdpath $cmd } - lset command_line $i $fullpath + lset command_line $i $cmdpath } # handle piped commands, e.g. `exec A | B`