Skip to content

Commit

Permalink
global: avoid raw word splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 30, 2024
1 parent d9faeb3 commit b55c400
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions .srcoption
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--exclude=./?.sh
--exclude=./test/install
--exclude=./ble.sh
--exclude=./gh[0-9][0-9][0-9][0-9]{,.*}
GNUmakefile
ble.pp
blerc.template
Expand Down
13 changes: 7 additions & 6 deletions docs/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- progcomp: fix a bug that `x` at the end of the last completion is trimmed `#D2308` xxxxxxxx
- main: fix attach failure with `--attach=prompt` in Bash 5.3 POSIX mode `#D2267` 49845707
- syntax: fix a problem that `$_` is not preserved `#D2269` e053690d
- keymap/vi: support bash-5.3 readline bindable function `bash-vi-complete` in `vi_nmap` `#D2305` xxxxxxxx
- keymap/vi: support bash-5.3 readline bindable function `bash-vi-complete` in `vi_nmap` `#D2305` 55e0ee71
- bgproc: support opts `kill9-timeout=TIMEOUT` `#D2034` 3ab41652
- progcomp(cd): change display name and support mandb desc (requested by EmilySeville7cfg) `#D2039` 74402098
- cmdspec: add completion options for builtins (motivated by EmilySeville7cfg) `#D2040` 9bd24691
Expand Down Expand Up @@ -71,10 +71,10 @@
- complete: support completion for `execute-named-command` `#D2288` 4fee44e6
- complete: support `ble-face menu_complete_{match,selected}` (requested by simonLeary42) `#D2291` 31f264ad
- edit: support `bleopt history_default_point={preserve,begin,end,near,far,{beginning,end}-of-line,preserve-column,...}` (requested by miltieIV2) `#D2297` 37291ff1
- edit: support `bleopt undo_point={first,last,near,auto}` `#D2303` xxxxxxxx
- keymap/vi: add readline-compatible widgets for `vi_imap` and `vi_nmap` (requested by excited-bore) `#D2304` xxxxxxxx
- edit: support bash-5.2 readline bindable function `vi-edit-and-execute-command` `#D2306` xxxxxxxx
- edit: support readline bindable function `paste-from-buffer` in more environments `#D2307` xxxxxxxx
- edit: support `bleopt undo_point={first,last,near,auto}` `#D2303` 99af0ece
- keymap/vi: add readline-compatible widgets for `vi_imap` and `vi_nmap` (requested by excited-bore) `#D2304` d7ec488a
- edit: support bash-5.2 readline bindable function `vi-edit-and-execute-command` `#D2306` c395eb33
- edit: support readline bindable function `paste-from-clipboard` in more environments `#D2307` 17646524

## Changes

Expand All @@ -101,7 +101,7 @@
- complete: attempt pathname expansions of incomplete pattern for `COMPV` (reported by mcepl) `#D2278` 6a426954
- make: save commit id and branch name with `git archive` (requested by LecrisUT, blackteahamburger) `#D2290` 31f264ad
- edit: revert edits with widget `discard-line` (reported by dezza) `#D2301` 3b2b4b81
- vi_nmap: fix cursor position after <kbd>C-o</kbd> `#D2302` xxxxxxxx
- vi_nmap: fix cursor position after <kbd>C-o</kbd> `#D2302` c106239a

## Fixes

Expand Down Expand Up @@ -299,6 +299,7 @@
- global: normalize quoting of function names of the form `prefix:$name` `#D2296` 3d7c98bb
- global: use `[:blank:]` instead of `[:space:]` `#D2299` e2fd8f0f
- global: rename `ret` not used as `REPLY` `#D2300` 86cbf78e
- global: avoid raw word splitting `#D2309` xxxxxxxx

<!---------------------------------------------------------------------------->
# ble-0.4.0-devel3
Expand Down
5 changes: 5 additions & 0 deletions note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7730,6 +7730,11 @@ bash_tips

2024-12-30

* global: avoid raw word splitting [#D2309]

未だ $bytes 等の様に quote されていない箇所があって気になるので、
"ble/string#split-words" や "ble/util/assign-words" を使う様に修正する。

* progcomp: fix a bug that "x" at the end of the last completion is trimmed [#D2308]

l ~/.opt/tilix を補完しようとすると何故か "~/.opt/tili " になってしまう。色々
Expand Down
10 changes: 6 additions & 4 deletions src/decode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,9 @@ function ble-decode-char/.getent {
if [[ $csistat && ! ${ent%_} ]]; then
if ((csistat==_ble_decode_KCODE_ERROR)); then
if [[ $bleopt_decode_error_cseq_vbell ]]; then
local ret; ble-decode-unkbd ${_ble_decode_char2_seq//_/ } $char
local ret
ble/string#split ret "${_ble_decode_char2_seq//_/ } $char"
ble-decode-unkbd "${ret[@]}"
ble/term/visible-bell "unrecognized CSI sequence: $ret"
fi
[[ $bleopt_decode_error_cseq_abell ]] && ble/term/audible-bell
Expand Down Expand Up @@ -4178,13 +4180,13 @@ function ble/builtin/bind/.process {
[[ -s "$_ble_base_run/$$.bind.save" ]] &&
source "$_ble_base_run/$$.bind.save"
[[ $opt_print ]] &&
builtin bind ${opt_keymap:+-m $opt_keymap} -$opt_print
builtin bind ${opt_keymap:+-m "$opt_keymap"} -"$opt_print"
declare rlfunc
for rlfunc in "${opt_queries[@]}"; do
builtin bind ${opt_keymap:+-m $opt_keymap} -q "$rlfunc"
builtin bind ${opt_keymap:+-m "$opt_keymap"} -q "$rlfunc"
done )
elif [[ $opt_print ]]; then
builtin bind ${opt_keymap:+-m $opt_keymap} -$opt_print
builtin bind ${opt_keymap:+-m "$opt_keymap"} -"$opt_print"
fi
fi

Expand Down
3 changes: 2 additions & 1 deletion src/edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11597,7 +11597,8 @@ if [[ $bleopt_internal_suppress_bash_output ]]; then
local content cmd
ble/util/readfile content "$file"
>| "$file"
for cmd in $content; do
ble/string#split-words content "$content"
for cmd in "${content[@]}"; do
case $cmd in
(eof)
# C-d
Expand Down
6 changes: 3 additions & 3 deletions src/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4016,7 +4016,7 @@ else
local fmt=$3 time=$4
ble/util/assign "$2" "ble/bin/date +\"\$fmt\" $time"
else
ble/bin/date +"$1" $2
ble/bin/date +"$1" ${2+"$2"}
fi
}
fi
Expand Down Expand Up @@ -7716,14 +7716,14 @@ else
fi

local bytes byte
ble/util/assign bytes '
ble/util/assign-words bytes '
local IFS=
while ble/bash/read -n 1 byte; do
builtin printf "%d " "'\''$byte"
done <<< "$s"
IFS=$_ble_term_IFS
'
ble/encoding:"$bleopt_input_encoding"/b2c $bytes
ble/encoding:"$bleopt_input_encoding"/b2c "${bytes[@]}"
}
fi

Expand Down

0 comments on commit b55c400

Please sign in to comment.