Skip to content

Commit

Permalink
edit: fixup b8c2ca6
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Apr 10, 2020
1 parent b58f006 commit fe78bd6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions ble.pp
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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" ||
Expand Down
2 changes: 1 addition & 1 deletion src/edit.sh
Expand Up @@ -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'
Expand Down

0 comments on commit fe78bd6

Please sign in to comment.