JohnSundell / ShellOut

Easily run shell commands from a Swift script or command line tool
MIT License
870 stars 83 forks source link

Suppress git password prompts by default #48

Closed finestructure closed 4 years ago

finestructure commented 4 years ago

When pulling/cloning a Github repository you can end up with a password prompt:

[ INFO ] cloning https://github.com/SwiftyBeaver/AES256CBC.git to /Users/sas/Projects/SPI-Server/SPI-checkouts/github.com-swiftybeaver-aes256cbc
Username for 'https://github.com':

This PR adds a prefix env GIT_TERMINAL_PROMPT=0 to the relevant git commands to suppress this (which will typically lead to a failure).

In the contexts where ShellOut is typically used (automation) this should be preferable to being stuck at the prompt, which is why I've set it to be the default for the allowingPrompt: Bool argument.

finestructure commented 4 years ago

Yikes, too fast - I meant to put this back into draft mode! :)

I found out yesterday evening that it might lead to a crash on Linux when there is no terminal: https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/58

I'm still trying to reproduce it but it may be safer not to suppress prompts by default. For instance, this could lead to process crashes in docker containers. Sorry for the lack of detail but I'm still investigating...

JohnSundell commented 4 years ago

No worries, I still haven't released an official version with this change. Do you mind submitting a PR that changes the default value, for now?

finestructure commented 4 years ago

Sure, here you go! #50