git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: GIT_TERMINAL_PROMPT environment variable isn't honored properly

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jun 29, 2021, 13:52 UTC
Message-ID
<YNslktip/qknZoFf@camp.crustytoothpaste.net>
In-Reply-To
<CA+B51BHBoDn+xFXOXWe0SvRzzuPo+YYj63f0dyafJELbBTgGbw@mail.gmail.com>
On 2021-06-29 at 13:46:44, Ondrej Pohorelsky wrote:
Show 7 quoted lines
> 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

Show 15 quoted lines
> $ 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
Previous: Ondrej PohorelskyNext: Ondrej Pohorelsky
Message 2 of 3 in “GIT_TERMINAL_PROMPT environment variable isn't honored properly”
  1. Ondrej PohorelskyJun 29, 2021
  2. brian m. carlsonJun 29, 2021
  3. Ondrej PohorelskyJun 29, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.