Repository navigation
Use readline for reading git commit messages - #8
Conversation
This way, you can use the arrow keys, etc. to edit input, and they work, rather than outputting control sequences.
|
It seems this breaks the build. Investigating. |
|
That gets close, and I like how you use I will put something together along the lines of what you suggested that uses the |
|
excellent, thanks! |
ksh does not support readline with read. zsh supports readline with varedit, but its input cannot be fed with a pipe, which causes the test suite to hang, waiting on the tty's stdin.
There was a problem hiding this comment.
On line 115 below (originally 105),
typeset comment="${4:-}"
I noticed you provide an empty default here. Is this not equivalent?
typeset comment="$4"
If there is some nuance I am unaware of, I should also change this line to match that style.
There was a problem hiding this comment.
usually, the empty defaults are for explicit non-zero checks later in the code. I don't see that here, so it is either old code, or I changed my mind about the calling semantics and didn't change the variable declaration.
should be safe just to say "$1"
|
The test suite hangs here in the zsh test run, which implies Also, I could not get any combination of quoting and escaping that would pass |
|
sure, let me take a look. |
|
Hmm.. looks like there are local perhaps, instead of a _prompt_cmd function, there should be a function whose goal is to do the appropriate thing and return a comment string. Maybe something like: _add_composure_file(){
...
if [ -z "$comment" ]; then
comment="$(_prompt_for_git_comment)"
fi
git commit -m "... $comment"
}
|
|
I like that. I'll make the change. |
The prompt must be displayed on stderr, or else it will become part of the result, since stdout is used to pass the result back to the caller of _prompt().
|
How does this look? Also, what ksh failures were you referring to? |
|
Looks good. Ksh: I was seeing some transient test errors in ksh with the second _add_composure_file test. Not sure what was going on, and I haven't been able to reproduce the problem in a couple of days. Onward and upward! |
Use readline for reading git commit messages
This way, you can use the arrow keys, etc. to edit input, and they work, rather than outputting control sequences.
I believe this is the only instance of reading user input where readline is useful.