std.process - avoid interaction with parent shell

H. S. Teoh hsteoh at
Mon Jul 20 21:24:04 UTC 2020

On Mon, Jul 20, 2020 at 04:55:52PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote:
> I am doing some scripting via D, and using std.process.execute to git
> clone things.
> I don't want any user interaction. Occasionally, I get a repository
> that no longer exists (404). Then git comes up and asks for a
> username/password. I want it to just fail. Apparently git has no
> option to be non-interactive, it supposedly checks stdin to see if
> it's a tty, and only errors if it's not.

Try --no-pager perhaps?  Not sure if that would help, since this isn't
technically a pager that's prompting you.

Another way is to take a look at std.process.execute's implementation. I
believe it's just a wrapper around spawnProcess. What you want is to
adapt that implementation so that it closes stdin before fork-n-exec'ing
git; that should stop any prompts.

One thing to be aware of is that it may not necessarily be git itself
that's prompting you; it could be a helper program like a password
manager that creates the prompt. In that case you probably have to find
out what it is, and disable it somehow (usually by overriding some
environment variable that gets passed to the git child process).


Ph.D. = Permanent head Damage

More information about the Digitalmars-d-learn mailing list