diff --git a/ble.pp b/ble.pp index f1619fc1..77788262 100644 --- a/ble.pp +++ b/ble.pp @@ -184,11 +184,21 @@ function ble/bin/.freeze-utility-path { ((!fail)) } +if ((_ble_bash>=40000)); then + function ble/bin#has { type "$@" &>/dev/null; } +else + function ble/bin#has { + local cmd + for cmd; do type "$cmd" || return 1; done &>/dev/null + return 0 + } +fi + # POSIX utilities _ble_init_posix_command_list=(sed date rm mkdir mkfifo sleep stty sort awk chmod grep cat wc mv sh) function ble/.check-environment { - if ! type "${_ble_init_posix_command_list[@]}" &>/dev/null; then + if ! ble/bin#has "${_ble_init_posix_command_list[@]}" &>/dev/null; then local cmd commandMissing= for cmd in "${_ble_init_posix_command_list[@]}"; do if ! type "$cmd" &>/dev/null; then @@ -205,7 +215,7 @@ function ble/.check-environment { export PATH=${default_path}${PATH:+:}${PATH} [[ :$PATH: == *:/bin:* ]] || PATH=/bin${PATH:+:}$PATH [[ :$PATH: == *:/usr/bin:* ]] || PATH=/usr/bin${PATH:+:}$PATH - if ! type "${_ble_init_posix_command_list[@]}" &>/dev/null; then + if ! ble/bin#has "${_ble_init_posix_command_list[@]}" &>/dev/null; then PATH=$original_path return 1 fi @@ -533,7 +543,7 @@ function ble-update { fi # check git, gawk - if ! type git gawk &>/dev/null; then + if ! ble/bin#has git gawk &>/dev/null; then local command for command in git gawk; do type "$command" || diff --git a/src/edit.sh b/src/edit.sh index 4e4e8b4f..04d46df9 100644 --- a/src/edit.sh +++ b/src/edit.sh @@ -205,7 +205,7 @@ function ble-edit/prompt/initialize { fi elif [[ $OSTYPE == msys* ]]; then # msys64/etc/bash.bashrc に倣う - if type id getent &>/dev/null; then + if ble/bin#has id getent &>/dev/null; then local id getent ble/util/assign id 'id -G' ble/util/assign getent 'getent -w group S-1-16-12288'