Re: [PATCH 1/2] maint: commit-msg: fix terminal corruption when re-editi
From:
Collin Funk
Subject:
Re: [PATCH 1/2] maint: commit-msg: fix terminal corruption when re-editing
Date:
Sat, 29 Nov 2025 13:46:17 -0800
User-agent:
Gnus/5.13 (Gnus v5.13)
PƔdraig Brady <P@draigBrady.com> writes:
> * scripts/git-hooks/commit-msg: Explicitly connect the editor to
> /dev/tty, so that it can restore terminal settings appropriately.
> ---
> scripts/git-hooks/commit-msg | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/git-hooks/commit-msg b/scripts/git-hooks/commit-msg
> index bdea8c38d..05dce1ebb 100755
> --- a/scripts/git-hooks/commit-msg
> +++ b/scripts/git-hooks/commit-msg
> @@ -49,7 +49,7 @@ sub re_edit($)
>
> warn "Interrupt (Ctrl-C) to abort...\n";
>
> - system 'sh', '-c', "$editor $log_file";
> + system 'sh', '-c', "$editor $log_file </dev/tty >/dev/tty 2>&1";
> ($? & 127) || ($? >> 8)
> and die "$ME: $log_file: the editor ($editor) failed, aborting\n";
> }
Both patches look good to me.
I don't think it is a problem in this case, but does Perl have no way to
execute a subprocess without worrying about quoting, e.g.,
subprocess.run(..., shell=False) in Python [1]? I couldn't find any
functionality like that online, but maybe the Perl people want to leave
that to external libraries.
Collin
[1] https://docs.python.org/3/library/subprocess.html#subprocess.run