sarugaku / shellingham

Tool to Detect Surrounding Shell
ISC License
227 stars 33 forks source link

Failure to resolve sh -c bash #87

Open arogozhnikov opened 6 months ago

arogozhnikov commented 6 months ago

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.

uranusjr commented 6 months ago

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