All of lore.kernel.org
 help / color / mirror / Atom feed
* GIT_TERMINAL_PROMPT environment variable isn't honored properly
@ 2021-06-29 13:46 Ondrej Pohorelsky
  2021-06-29 13:52 ` brian m. carlson
  0 siblings, 1 reply; 3+ messages in thread
From: Ondrej Pohorelsky @ 2021-06-29 13:46 UTC (permalink / raw)
  To: git; +Cc: peff

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
$ 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


I've tested this issue on Fedora 34 with git-2.32.0 and Ubuntu 20.10
with git-2.27.0 and I successfully reproduced this bug.
Sadly I didn't manage to figure out why this is happening, that's why
I'm only filling a bug.

This variable was introduced in commit
"e652c0eb5d772076f92245c7e076bf6aaf6af223" by Jeff King, that's why
I'm adding him to CC.


Best regards,
Ondřej Pohořelský


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GIT_TERMINAL_PROMPT environment variable isn't honored properly
  2021-06-29 13:46 GIT_TERMINAL_PROMPT environment variable isn't honored properly Ondrej Pohorelsky
@ 2021-06-29 13:52 ` brian m. carlson
  2021-06-29 14:37   ` Ondrej Pohorelsky
  0 siblings, 1 reply; 3+ messages in thread
From: brian m. carlson @ 2021-06-29 13:52 UTC (permalink / raw)
  To: Ondrej Pohorelsky; +Cc: git, peff

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GIT_TERMINAL_PROMPT environment variable isn't honored properly
  2021-06-29 13:52 ` brian m. carlson
@ 2021-06-29 14:37   ` Ondrej Pohorelsky
  0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Pohorelsky @ 2021-06-29 14:37 UTC (permalink / raw)
  To: brian m. carlson, Ondrej Pohorelsky, git, peff

Thank you very much for your explanation, this makes perfect sense now!

Best regards,
Ondřej Pohořelský

On Tue, Jun 29, 2021 at 3:53 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-29 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 13:46 GIT_TERMINAL_PROMPT environment variable isn't honored properly Ondrej Pohorelsky
2021-06-29 13:52 ` brian m. carlson
2021-06-29 14:37   ` Ondrej Pohorelsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.