Search code examples
gitbashcygwinsh

Does git use sh? If so can it be changed to use bash?


When I run a git command I often get

sh: line 0: igncr: invalid option name

As output. This is caused by a setting I have to make cygwin tolerable. IT looks like git is spawning a sh process to run in. Can I configure this to be a bash shell instead?

It doesn't add much but as requested here is the git command

gt ad -p A/B/C.csproj

The shell commands causing failure are

export SHELLOPTS
set -o igncr

If run with GIT_TRACE=1

trace: exec: 'git-ad' '-p' 'A/B/C.csproj'
trace: run_command: 'git-ad' '-p' 'A/B/C.csproj'
trace: alias expansion: ad => 'add'
trace: built-in: git 'add' '-p' 'A/B/C.csproj'
trace: run_command: 'add--interactive' '--patch' '--' 'A/B/C.csproj'
trace: exec: 'git-add--interactive' '--patch' '--' 'A/B/C.csproj'
trace: run_command: 'git-add--interactive' '--patch' '--' 'A/B/C.csproj'
trace: built-in: git 'rev-parse' '--show-prefix'
trace: built-in: git 'config' '--get-colorbool' 'color.interactive' 'false'
trace: built-in: git 'config' '--get-color' 'color.interactive.prompt' 'bold blu                      e'
trace: built-in: git 'config' '--get-color' 'color.interactive.header' 'bold'
trace: built-in: git 'config' '--get-color' 'color.interactive.help' 'red bold'
trace: built-in: git 'config' '--get' 'color.interactive.help'
trace: built-in: git 'config' '--get-color' 'color.interactive.error' 'red bold'
trace: built-in: git 'config' '--get-colorbool' 'color.diff' 'false'
trace: built-in: git 'config' '--get-color' 'color.diff.frag' 'cyan'
trace: built-in: git 'config' '--get-color' 'color.diff.plain' ''
trace: built-in: git 'config' '--get-color' 'color.diff.old' 'red'
trace: built-in: git 'config' '--get-color' 'color.diff.new' 'green'
trace: built-in: git 'config' '--get-color' '' 'reset'
trace: built-in: git 'config' '--bool' '--get' 'interactive.singlekey'
trace: built-in: git 'rev-parse' '--git-dir'
trace: built-in: git 'update-index' '--refresh'
trace: built-in: git 'ls-files' '--' 'A/B/C.csproj'
sh: line 0: igncr: invalid option name
trace: built-in: git 'diff-index' '--cached' '--numstat' '--summary' 'HEAD' '--' 'A/B/C.csproj'
trace: built-in: git 'diff-files' '--numstat' '--summary' '--raw' '--' 'A/B/C.csproj'
trace: built-in: git 'diff-files' '-p' '--' 'A/B/C.csproj'
trace: built-in: git 'diff-files' '-p' '--color' '--' 'A/B/C.csproj'

Solution

  • Please run the failing git command prefixed with GIT_TRACE=1 to see the details of the failing shell command spawned, and take it from there...

    EDIT: After seeing the trace, given the fact that igncr is a cygwin specific bash option, consider adding a bash function to override the gt command and turn off that shell option.

    For example,

    gt () { (set +o igncr; git "$@";) }
    gt ls-files
    

    of course you should move the gt function to your .bashrc or similar.