sarugaku / shellingham

Tool to Detect Surrounding Shell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failure to resolve sh -c bash

arogozhnikov opened this issue · comments

Let me start from goal. I want to run typer --install-completions in container, I want this to be run automatically.

Sadly, this means command should run from sh. Usually no big deal as sh -c 'bash -lc do-whatever'. But typer uses shellingham to auto-identify shell.

And here we are (whole thing running from bash):

># python -c "import shellingham; print(shellingham.detect_shell())"
('bash', '/bin/bash') 
># sh -c 'python -c "import shellingham; print(shellingham.detect_shell())"'
('sh', 'sh')
># bash -c 'python -c "import shellingham; print(shellingham.detect_shell())"'
('bash', '/bin/bash')
># sh
># bash -c 'python -c "import shellingham; print(shellingham.detect_shell())"'
('sh', 'sh')  # WHYYY?

and I don't see a way to affect this or override it somehow - a single sh in chain, and shellingham says it is sh. Correspondingly typer won't install any completions.

I wonder if this is the same as #86. Some local debugging work would help a lot here.