{"thread":{"id":"56026","subject":"GIT_TERMINAL_PROMPT environment variable isn't honored properly","startedAt":"2021-06-29T13:47:00Z","lastAt":"2021-06-29T14:38:05Z","messageCount":3,"participants":["Ondrej Pohorelsky","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"428747","messageId":"CA+B51BHBoDn+xFXOXWe0SvRzzuPo+YYj63f0dyafJELbBTgGbw@mail.gmail.com","threadId":"56026","inReplyTo":null,"subject":"GIT_TERMINAL_PROMPT environment variable isn't honored properly","fromName":"Ondrej Pohorelsky","fromEmail":"opohorel@redhat.com","sentAt":"2021-06-29T13:46:44Z","receivedAt":"2021-06-29T13:47:00Z","isPatch":false,"sender":{"key":"opohorel@redhat.com","avatar":"https://avatars.githubusercontent.com/u/35430604?v=4"},"body":"Hi, we've run into an issue when running git as part of an automated system.\n\nWhen you set the GIT_TERMINAL_PROMPT environment variable as 0 you\nexpect git to die instead of trying to issue a prompt on the terminal.\n\n\n$ GIT_TERMINAL_PROMPT=0\n$ echo $GIT_TERMINAL_PROMPT\n0\n$ git clone https://github.com/some/non-existent-repo\nCloning into 'non-existent-repo'...\nUsername for 'https://github.com':\n\n\nYou get expected behaviour only when you set the GIT_TERMINAL_PROMPT\nvariable just before you run git clone.\n\n\n$ GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existent-repo\nCloning into 'non-existent-repo'...\nfatal: could not read Username for 'https://github.com': terminal\nprompts disabled\n\n\nI've tested this issue on Fedora 34 with git-2.32.0 and Ubuntu 20.10\nwith git-2.27.0 and I successfully reproduced this bug.\nSadly I didn't manage to figure out why this is happening, that's why\nI'm only filling a bug.\n\nThis variable was introduced in commit\n\"e652c0eb5d772076f92245c7e076bf6aaf6af223\" by Jeff King, that's why\nI'm adding him to CC.\n\n\nBest regards,\nOndřej Pohořelský\n\n"},{"id":"428748","messageId":"YNslktip/qknZoFf@camp.crustytoothpaste.net","threadId":"56026","inReplyTo":"CA+B51BHBoDn+xFXOXWe0SvRzzuPo+YYj63f0dyafJELbBTgGbw@mail.gmail.com","subject":"Re: GIT_TERMINAL_PROMPT environment variable isn't honored properly","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-06-29T13:52:18Z","receivedAt":"2021-06-29T13:52:55Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-06-29 at 13:46:44, Ondrej Pohorelsky wrote:\n> Hi, we've run into an issue when running git as part of an automated system.\n> \n> When you set the GIT_TERMINAL_PROMPT environment variable as 0 you\n> expect git to die instead of trying to issue a prompt on the terminal.\n> \n> \n> $ GIT_TERMINAL_PROMPT=0\n\nWhen you write this in the shell, the shell doesn't by default export\nthis variable to processes it invokes, like git.  If you want to do\nthat, you need to write:\n\n$ export GIT_TERMINAL_PROMPT=0\n\nor\n\n$ GIT_TERMINAL_PROMPT=0\n$ export GIT_TERMINAL_PROMPT\n\n> $ echo $GIT_TERMINAL_PROMPT\n> 0\n> $ git clone https://github.com/some/non-existent-repo\n> Cloning into 'non-existent-repo'...\n> Username for 'https://github.com':\n> \n> \n> You get expected behaviour only when you set the GIT_TERMINAL_PROMPT\n> variable just before you run git clone.\n> \n> \n> $ GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existent-repo\n> Cloning into 'non-existent-repo'...\n> fatal: could not read Username for 'https://github.com': terminal\n> prompts disabled\n\nWhen you write this, the variable is always exported to the command, since\nit's not possible to use export here and otherwise this syntax wouldn't\nbe very useful.\n\nHopefully this explains why you're seeing some different behavior\nbetween the two situations.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"428753","messageId":"CA+B51BGeqxryH6qZKAo3hbTZCFmprsHH4JYUkCFLVAMWGnV6_g@mail.gmail.com","threadId":"56026","inReplyTo":"YNslktip/qknZoFf@camp.crustytoothpaste.net","subject":"Re: GIT_TERMINAL_PROMPT environment variable isn't honored properly","fromName":"Ondrej Pohorelsky","fromEmail":"opohorel@redhat.com","sentAt":"2021-06-29T14:37:47Z","receivedAt":"2021-06-29T14:38:05Z","isPatch":false,"sender":{"key":"opohorel@redhat.com","avatar":"https://avatars.githubusercontent.com/u/35430604?v=4"},"body":"Thank you very much for your explanation, this makes perfect sense now!\n\nBest regards,\nOndřej Pohořelský\n\nOn Tue, Jun 29, 2021 at 3:53 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2021-06-29 at 13:46:44, Ondrej Pohorelsky wrote:\n> > Hi, we've run into an issue when running git as part of an automated system.\n> >\n> > When you set the GIT_TERMINAL_PROMPT environment variable as 0 you\n> > expect git to die instead of trying to issue a prompt on the terminal.\n> >\n> >\n> > $ GIT_TERMINAL_PROMPT=0\n>\n> When you write this in the shell, the shell doesn't by default export\n> this variable to processes it invokes, like git.  If you want to do\n> that, you need to write:\n>\n> $ export GIT_TERMINAL_PROMPT=0\n>\n> or\n>\n> $ GIT_TERMINAL_PROMPT=0\n> $ export GIT_TERMINAL_PROMPT\n>\n> > $ echo $GIT_TERMINAL_PROMPT\n> > 0\n> > $ git clone https://github.com/some/non-existent-repo\n> > Cloning into 'non-existent-repo'...\n> > Username for 'https://github.com':\n> >\n> >\n> > You get expected behaviour only when you set the GIT_TERMINAL_PROMPT\n> > variable just before you run git clone.\n> >\n> >\n> > $ GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existent-repo\n> > Cloning into 'non-existent-repo'...\n> > fatal: could not read Username for 'https://github.com': terminal\n> > prompts disabled\n>\n> When you write this, the variable is always exported to the command, since\n> it's not possible to use export here and otherwise this syntax wouldn't\n> be very useful.\n>\n> Hopefully this explains why you're seeing some different behavior\n> between the two situations.\n> --\n> brian m. carlson (he/him or they/them)\n> Toronto, Ontario, CA\n\n"}]}