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 18, 2020
1 parent 3031007 commit b9278bc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
29 changes: 18 additions & 11 deletions ble.pp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function ble/base/restore-POSIXLY_CORRECT {

if [[ $_ble_base ]]; then
if ! ble/base/unload-for-reload &>/dev/null; then
ble/util/print "ble.sh: ble.sh seems to be already loaded." >&2
builtin echo "ble.sh: an old version of ble.sh seems to be already loaded." >&2
return 1
fi
fi
Expand Down Expand Up @@ -275,18 +275,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
ble/util/print "ble.sh: modified PATH=${PATH::${#PATH}-${#original_path}}:\$PATH" >&2
fi

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

# 暫定的な ble/bin/$cmd 設定
Expand Down
29 changes: 24 additions & 5 deletions memo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,6 @@ bash_tips

[修正]

* 取り敢えずユーザー名はもし設定されていなければ設定する。
id -un でユーザー名は取得できる筈である。

* Haiku における問題

Haiku で ble-reload 時に変なメッセージが出る。
Expand Down Expand Up @@ -2533,12 +2530,13 @@ bash_tips

New features
- complete: support `bleopt complete_auto_wordbreaks` (suggestion by dylankb) `#D1219` c294e31
- main: check `~/.config/blesh/init.sh` `#D1224` 0000000
- main: check `~/.config/blesh/init.sh` `#D1224` a82f961

Fix
- util (ble/builtin/trap): fix argument analysis for the form `trap INT` (reported by dylankb) `#D1221` db8b0c2
- main: fix an error message on ristricted shells `#D1220` b726225
- edit: fix a bug that the shell hangs with `source ble.sh --noattach && ble-attach` (reported by dylankb) `#D1223` 59c1ce4
- edit: fix a bug that the shell hangs with `source ble.sh --noattach && ble-attach` (reported by dylankb) `#D1223` 59c1ce4 3031007
- main: workaround cygwin uninitialized environment `#D1225` `#D1226`

2019-03-21 -- 2020-01-12 (#D1015...#D1215) df4feaa...c74abc5

Expand Down Expand Up @@ -3674,6 +3672,27 @@ bash_tips

2020-01-18

* cygwin: cygwin console で USER が空になっている [#D1226]
取り敢えずユーザー名はもし設定されていなければ設定する。
id -un でユーザー名は取得できる筈である。

これも #D1225 と一緒に対応した。

* cygwin: cygwin console で "-u指定されたファイルが見つかりません" エラー [#D1225]

これは 3.0.7 でも発生している。恐らく補完だろう。
"-u指定されたファイルが見つかりません" というメッセージが表示される。
64bit でも 32bit でも同様に出る。中で更に起動した Bash では再現しない。

この行が駄目だった。
ble/util/assign-array arr 'ble/bin/sort -u <<< "$compgen"' # 1 fork/exec

そして ble/bin/sort を見てみると
ble/bin/sort() { '/cygdrive/c/WINDOWS/system32/sort' "$@"; }
等という事になっていた。道理で駄目な訳だ。
他にも Windows に同盟のコマンドがあるという事がありそう。
うーん。面倒なのでもう先頭に追加してしまう事にする。。

* main: .blerc がない時は ~/.config/blesh/... から読み取っても良いのでは [#D1224]
然しどういう名前が良いだろうか。
~/.config/blesh/blerc なのか、
Expand Down

0 comments on commit b9278bc

Please sign in to comment.