Skip to content

Commit

Permalink
global: pick fixes and changes from ble-0.1 backports
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Aug 24, 2022
1 parent 8f0acf3 commit 013eb1c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 1 addition & 3 deletions ble-core.sh
Expand Up @@ -523,8 +523,6 @@ fi
## @param[in] command...
## 実行するコマンドを指定します。
##
_ble_util_read_stdout_tmp="$_ble_base_run/$$.ble_util_assign.tmp"

_ble_util_assign_base=$_ble_base_run/$$.util.assign.tmp
_ble_util_assign_level=0
if ((_ble_bash>=40000)); then
Expand Down Expand Up @@ -568,7 +566,7 @@ else
local _ble_local_ret=$?
TMOUT= IFS= builtin read -r -d '' "$1" < "$_ble_local_tmpfile"
ble/util/assign/.rmtmp
builtin eval "$1=\${$1%$_ble_term_nl}"
builtin eval "$1=\${$1%\$_ble_term_nl}"
return "$_ble_local_ret"
}
fi
Expand Down
2 changes: 1 addition & 1 deletion ble-decode.sh
Expand Up @@ -1743,7 +1743,7 @@ function ble-decode-bind/.generate-source-to-unbind-default/.process {

function ble-decode/bind {
local file=$_ble_base_cache/ble-decode-bind.$_ble_bash.$bleopt_input_encoding.bind
[[ -s $file && $file -nt $_ble_base/bind.sh ]] || source "$_ble_base/bind.sh"
[[ -s $file && $file -nt $_ble_base/bind.sh ]] || source "$_ble_base/bind.sh"

# * 一時的に 'set convert-meta off' にする。
#
Expand Down
4 changes: 2 additions & 2 deletions ble-edit.sh
Expand Up @@ -723,7 +723,7 @@ function ble-edit/draw/trace/process-csi-sequence {
# HVP "CSI f"
local -a params
ble/string#split-words params "${param//[^0-9]/ }"
params=("${params[@]/#/10#}")
params=("${params[@]/#/10#0}")
((x=params[1]-1))
((y=params[0]-1))
((x<0&&(x=0),x>=cols&&(x=cols-1),
Expand Down Expand Up @@ -7194,7 +7194,7 @@ function ble-edit/bind/.check-detach {
ble/textarea#render
ble/util/buffer.flush >&2
if ((_ble_bash>=40000)); then
READLINE_LINE=' stty sane;' READLINE_POINT=10
READLINE_LINE=' stty sane;' READLINE_POINT=11
printf %s "$READLINE_LINE"
fi
fi
Expand Down
11 changes: 7 additions & 4 deletions ble.pp
Expand Up @@ -52,7 +52,7 @@
_ble_bash=$((BASH_VERSINFO[0]*10000+BASH_VERSINFO[1]*100+BASH_VERSINFO[2]))

if [ "$_ble_bash" -lt 30000 ]; then
unset _ble_bash
unset -v _ble_bash
echo "ble.sh: bash with a version under 3.0 is not supported." >&2
return 1 2>/dev/null || exit 1
fi
Expand All @@ -67,21 +67,24 @@
esac

if ((BASH_SUBSHELL)); then
unset -v _ble_bash
builtin echo "ble.sh: ble.sh cannot be loaded into a subshell." >&2
return 1 2>/dev/null || builtin exit 1
elif [[ $- != *i* ]]; then
unset -v _ble_bash
case " ${BASH_SOURCE[*]##*/} " in
(*' .bashrc '* | *' .bash_profile '* | *' .profile '* | *' bashrc '* | *' profile '*) false ;;
esac &&
builtin echo "ble.sh: This is not an interactive session." >&2 || ((1))
return 1 2>/dev/null || builtin exit 1
elif ! [[ -t 0 && -t 1 ]]; then
unset -v _ble_bash
builtin echo "ble.sh: cannot find the correct TTY/PTY in this session." >&2
return 1 2>/dev/null || builtin exit 1
fi

if [[ -o posix ]]; then
unset _ble_bash
unset -v _ble_bash
echo "ble.sh: ble.sh is not intended to be used in bash POSIX modes (--posix)." >&2
return 1 2>/dev/null || exit 1
fi
Expand Down Expand Up @@ -117,13 +120,13 @@ function ble/restore-bash-options {

bind &>/dev/null # force to load .inputrc
if [[ ! -o emacs && ! -o vi ]]; then
unset _ble_bash
unset -v _ble_bash
echo "ble.sh: ble.sh is not intended to be used with the line-editing mode disabled (--noediting)." >&2
return 1
fi

if shopt -q restricted_shell; then
unset _ble_bash
unset -v _ble_bash
echo "ble.sh: ble.sh is not intended to be used in restricted shells (--restricted)." >&2
return 1
fi
Expand Down
1 change: 1 addition & 0 deletions cmap/default.sh
Expand Up @@ -81,6 +81,7 @@ function ble-bind-function-key+default {
# ble-bind --csi '6~' next

# 順番を固定
local ret
ble-decode-kbd/.gen-keycode insert
ble-decode-kbd/.gen-keycode home
ble-decode-kbd/.gen-keycode prior
Expand Down
4 changes: 2 additions & 2 deletions test/benchmark/benchmark-array-is-array.sh
Expand Up @@ -35,8 +35,8 @@ ble-measure 'ble/is-array2 arr' # 1439.90 usec/eval
# 3 compgen -A arrayvar を用いる方法 (完全)

function ble/is-array3 {
compgen -A arrayvar "$1" >| "$_ble_util_read_stdout_tmp" 2>/dev/null || return 1
local REPLY; read -r < "$_ble_util_read_stdout_tmp"
compgen -A arrayvar "$1" >| "$_ble_util_assign_base" 2>/dev/null || return 1
local REPLY; read -r < "$_ble_util_assign_base"
[[ $REPLY == "$1" ]]
}

Expand Down

0 comments on commit 013eb1c

Please sign in to comment.