git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Ondrej Pohorelsky <opohorel@redhat.com>
Cc: git@vger.kernel.org, peff@peff.net
Subject: Re: GIT_TERMINAL_PROMPT environment variable isn't honored properly
Date: Tue, 29 Jun 2021 13:52:18 +0000	[thread overview]
Message-ID: <YNslktip/qknZoFf@camp.crustytoothpaste.net> (raw)
In-Reply-To: <CA+B51BHBoDn+xFXOXWe0SvRzzuPo+YYj63f0dyafJELbBTgGbw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1424 bytes --]

On 2021-06-29 at 13:46:44, Ondrej Pohorelsky wrote:
> Hi, we've run into an issue when running git as part of an automated system.
> 
> When you set the GIT_TERMINAL_PROMPT environment variable as 0 you
> expect git to die instead of trying to issue a prompt on the terminal.
> 
> 
> $ GIT_TERMINAL_PROMPT=0

When you write this in the shell, the shell doesn't by default export
this variable to processes it invokes, like git.  If you want to do
that, you need to write:

$ export GIT_TERMINAL_PROMPT=0

or

$ GIT_TERMINAL_PROMPT=0
$ export GIT_TERMINAL_PROMPT

> $ echo $GIT_TERMINAL_PROMPT
> 0
> $ git clone https://github.com/some/non-existent-repo
> Cloning into 'non-existent-repo'...
> Username for 'https://github.com':
> 
> 
> You get expected behaviour only when you set the GIT_TERMINAL_PROMPT
> variable just before you run git clone.
> 
> 
> $ GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existent-repo
> Cloning into 'non-existent-repo'...
> fatal: could not read Username for 'https://github.com': terminal
> prompts disabled

When you write this, the variable is always exported to the command, since
it's not possible to use export here and otherwise this syntax wouldn't
be very useful.

Hopefully this explains why you're seeing some different behavior
between the two situations.
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2021-06-29 13:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29 13:46 GIT_TERMINAL_PROMPT environment variable isn't honored properly Ondrej Pohorelsky
2021-06-29 13:52 ` brian m. carlson [this message]
2021-06-29 14:37   ` Ondrej Pohorelsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YNslktip/qknZoFf@camp.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=opohorel@redhat.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).