Fix ext-helpers with older bash versions

See Midnight Commander commit 436296f, blindly trusting it.

wc(1) could be used unconditionally but let's make it clear.
This commit is contained in:
Přemysl Eric Janouch 2020-10-20 03:42:14 +02:00
parent 63e7895905
commit 6f40b8db3a
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 7 additions and 1 deletions

View File

@ -100,11 +100,17 @@ there's no way to invoke `prompt_again()` from a `bind -x` handler but we can
work around it by submitting a blank line: work around it by submitting a blank line:
---- ----
sdn-cursor () {
if [[ $BASH_VERSINFO -lt 5 ]]
then echo -n "$SDN_L" | wc -m
else echo "$SDN_P"
fi
}
sdn-navigate () { sdn-navigate () {
SDN_L=$READLINE_LINE SDN_P=$READLINE_POINT SDN_L=$READLINE_LINE SDN_P=$READLINE_POINT
READLINE_LINE= READLINE_LINE=
while eval "`sdn "$SDN_L" "$SDN_P"`"; do while eval "`sdn "$SDN_L" "$(sdn-cursor)"`"; do
[[ -z "$cd" ]] || cd "$cd" [[ -z "$cd" ]] || cd "$cd"
[[ -z "$insert" ]] || { [[ -z "$insert" ]] || {
SDN_L="${SDN_L:0:$SDN_P}$insert ${SDN_L:$SDN_P}" SDN_L="${SDN_L:0:$SDN_P}$insert ${SDN_L:$SDN_P}"