mirror of
https://github.com/lotabout/skim.git
synced 2026-09-10 07:16:23 -04:00
replace undefined awk behaviour (#1016)
I encountered a bug with the CTRL-R history behaviour in bash, and tracked it down to these awk commands. I'm not sure what changed, but according to the documentation `\0` is undefined behaviour: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/awk.html#tagtcjh_15 I've replaced the `\0` escape sequences with the `%c` conversion which converts the int argument to a single byte character. Ref: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap05.html
This commit is contained in:
parent
c0a9be6b5f
commit
b9c3de302b
|
|
@ -57,11 +57,11 @@ if [[ $- =~ i ]]; then
|
|||
last_hist=$(HISTTIMEFORMAT='' builtin history 1) awk -v last_hist="$last_hist" -v c_idx="$c_idx" -v c_reset="$c_reset" '
|
||||
BEGIN { HISTCMD = last_hist + 1; cmd = ""; idx = 0 }
|
||||
/^\t/ {
|
||||
if (cmd != "" && !seen[cmd]++) printf "%s%d%s\t%s\0", c_idx, HISTCMD - idx, c_reset, cmd
|
||||
if (cmd != "" && !seen[cmd]++) printf "%s%d%s\t%s%c", c_idx, HISTCMD - idx, c_reset, cmd, 0
|
||||
idx++; cmd = substr($0, 2); sub(/^[ *]/, "", cmd); next
|
||||
}
|
||||
{ cmd = cmd "\n" $0 }
|
||||
END { if (cmd != "" && !seen[cmd]++) printf "%s%d%s\t%s\0", c_idx, HISTCMD - idx, c_reset, cmd }
|
||||
END { if (cmd != "" && !seen[cmd]++) printf "%s%d%s\t%s%c", c_idx, HISTCMD - idx, c_reset, cmd, 0 }
|
||||
' |
|
||||
SKIM_DEFAULT_OPTIONS="$SKIM_DEFAULT_OPTIONS -n2.. --bind=ctrl-r:toggle-sort $SKIM_CTRL_R_OPTS --no-multi --read0 $ansi_opt" $(__skimcmd) --query "$READLINE_LINE"
|
||||
) || return
|
||||
|
|
|
|||
Loading…
Reference in a new issue