Skip to content

Commit

Permalink
complete: use "awk" for batch "quote-insert"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 19, 2021
1 parent 7db3d2b commit a0b2ad2
Show file tree
Hide file tree
Showing 6 changed files with 651 additions and 136 deletions.
17 changes: 11 additions & 6 deletions ble.pp
Expand Up @@ -684,30 +684,35 @@ function ble/.check-environment {
fi

# src/util で awk を使う
_ble_bin_awk_type=
function ble/bin/awk/.instantiate {
local path q=\' Q="'\''"
if [[ $OSTYPE == solaris* ]] && type /usr/xpg4/bin/awk >/dev/null; then
# Solaris の既定の awk は全然駄目なので /usr/xpg4 以下の awk を使う。
_ble_bin_awk_type=xpg4
function ble/bin/awk { /usr/xpg4/bin/awk -v AWKTYPE=xpg4 "$@"; }
elif ble/util/assign path "builtin type -P -- nawk 2>/dev/null" && [[ $path ]]; then
_ble_bin_awk_type=nawk
builtin eval "function ble/bin/awk { '${path//$q/$Q}' -v AWKTYPE=nawk \"\$@\"; }"
elif ble/util/assign path "builtin type -P -- mawk 2>/dev/null" && [[ $path ]]; then
_ble_bin_awk_type=mawk
builtin eval "function ble/bin/awk { '${path//$q/$Q}' -v AWKTYPE=mawk \"\$@\"; }"
elif ble/util/assign path "builtin type -P -- gawk 2>/dev/null" && [[ $path ]]; then
_ble_bin_awk_type=gawk
builtin eval "function ble/bin/awk { '${path//$q/$Q}' -v AWKTYPE=gawk \"\$@\"; }"
elif ble/util/assign path "builtin type -P -- awk 2>/dev/null" && [[ $path ]]; then
local version type
local version
ble/util/assign version '"$path" --version 2>&1'
if [[ $version == *'GNU Awk'* ]]; then
type=gawk
_ble_bin_awk_type=gawk
elif [[ $version == *mawk* ]]; then
type=mawk
_ble_bin_awk_type=mawk
elif [[ $version == 'awk version '[12][0-9][0-9][0-9][01][0-9][0-3][0-9] ]]; then
type=nawk
_ble_bin_awk_type=nawk
else
type=unknown
_ble_bin_awk_type=unknown
fi
builtin eval "function ble/bin/awk { '${path//$q/$Q}' -v AWKTYPE=$type \"\$@\"; }"
builtin eval "function ble/bin/awk { '${path//$q/$Q}' -v AWKTYPE=$_ble_bin_awk_type \"\$@\"; }"
else
return 1
fi
Expand Down
2 changes: 2 additions & 0 deletions docs/ChangeLog.md
Expand Up @@ -202,6 +202,7 @@
- util (`ble/util/readfile`): fix a bug of always exiting with 1 in `bash <= 3.2` (reported by laoshaw) `#D1678` 61705bf
- trace: fix wrong positioning of the ellipses on overflow `#D1684` b90ac78
- complete: do not generate keywords for quoted command names `#D1691` 60d244f
- menu (menu-style:align): fix the failure of delaying `ble/canvas/trace` on items (motivated by banoris) `#D1710` acc9661
- complete: fix empty completions with `FIGNORE` (reported by seanfarley) `#D1711` 144ea5d
- main: fix the message of owner errors of cache directories (reported by zim0369) `#D1712` b547a41
- util (`ble/string#escape-for-bash-specialchars`): fix escaping of TAB `#D1713` 0000000
Expand Down Expand Up @@ -231,6 +232,7 @@
- prompt: use `${PS1@P}` when the prompt contains only safe prompt sequences `#D1617` 8b5da08
- prompt: fix not properly set `$?` in `${PS1@P}` evaluation (reported by nihilismus) `#D1644` 521aff9
- decode: cache `inputrc` translations `#D1652` 994e2a5
- complete: use `awk` for batch `quote-insert` (motivated by banoris) `#D1714` 0000000

## Compatibility

Expand Down

0 comments on commit a0b2ad2

Please sign in to comment.