Skip to content

Commit

Permalink
main: workaround cygwin uninitialized environment
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 24, 2020
1 parent bc62a18 commit c27a3bb
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions ble.pp
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,25 @@ function ble/.check-environment {

# try to fix PATH
local default_path=$(command -p getconf PATH 2>/dev/null)
if [[ $default_path ]]; then
local original_path=$PATH
export PATH=${PATH}${PATH:+:}${default_path}
[[ :$PATH: == *:/usr/bin:* ]] || PATH=$PATH${PATH:+:}/usr/bin
[[ :$PATH: == *:/bin:* ]] || PATH=$PATH${PATH:+:}/bin
if ! type "${_ble_init_posix_command_list[@]}" &>/dev/null; then
PATH=$original_path
return 1
fi
[[ $default_path ]] || return 1

local original_path=$PATH
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
PATH=$original_path
return 1
fi
echo "ble.sh: modified PATH=${PATH::${#PATH}-${#original_path}}:\$PATH" >&2
fi

echo "ble.sh: modified PATH=\$PATH${PATH:${#original_path}}" >&2
if [[ ! $USER ]]; then
echo "ble.sh: Insane environment: \$USER is empty." >&2
if type id &>/dev/null; then
export USER=$(id -un)
echo "ble.sh: modified USER=$USER" >&2
fi
fi

# 暫定的な ble/bin/$cmd 設定
Expand Down

0 comments on commit c27a3bb

Please sign in to comment.