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 896fa3b commit 6aa1732
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions ble.pp
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,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
2 changes: 1 addition & 1 deletion src/edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7134,7 +7134,7 @@ function ble-edit/bind/.check-detach {
# epilogue によって detach 後の状態が壊されているので
# 改めて prologue を呼び出す必要がある。
# #D1130 #D1199 #D1223
ble-edit/exec:"$bleopt_internal_exec_type"/.eval-prologue
ble-edit/exec:"$bleopt_internal_exec_type"/.eval-prologue
fi

return 0
Expand Down

0 comments on commit 6aa1732

Please sign in to comment.