Re: [PATCH v1 1/8] compat/terminal: let prompt accept input from pipe
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 6, 2021, 23:37 UTC
- Message-ID
- <xmqqr1ijwi0i.fsf@gitster.g>
- In-Reply-To
- <20210506165102.123739-2-firminmartin24@gmail.com>
Firmin Martin <firminmartin24@gmail.com> writes:
Show 10 quoted lines
> Currently, git_prompt ignores input coming from anywhere other than > terminal (pipe, redirection etc.) meaning that standard prompt > auto-answering methods would have no effect: > > echo 'Y' | git ... > yes 'Y' | git ... > git ... <input.txt > > It also prevents git subcommands using git_prompt to be tested using > such methods.
For testing, wouldn't lib-terminal.sh be usable for your purpose? If not, what is the reason why it is insufficient? Can we fix that instead?
Allowing prompter to read from pipe has a big downside in the production code: you cannot pipe data into our command, and let it ask interactive questions from the end user by opening /dev/tty.
> This patch fixes this issue by considering standard input when !isatty(0). > It also rearranges the control flow to close input and output file handlers.
So this "fix" is probably very unwelcome, especially if done unconditionally.
Thanks.