Skip to content

Commit

Permalink
main: suppress non-interactive warnings from manually sourced startup…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
akinomyoga committed Oct 25, 2021
1 parent 0525528 commit 88e2df5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
6 changes: 4 additions & 2 deletions ble.pp
Expand Up @@ -142,8 +142,10 @@ function ble/debug/measure-set-timeformat {
builtin echo "ble.sh: ble.sh cannot be loaded into a subshell." >&3
return 1 2>/dev/null || builtin exit 1
elif [[ $- != *i* ]]; then
{ ((${#BASH_SOURCE[@]})) && case ${BASH_SOURCE[${#BASH_SOURCE[@]}-1]} in (*bashrc|*bash_profile) ;; (*) false ;; esac } ||
builtin echo "ble.sh: This is not an interactive session." >&3
case " ${BASH_SOURCE[*]##*/} " in
(*' .bashrc '* | *' .bash_profile '* | *' .profile '* | *' bashrc '* | *' profile '*) false ;;
esac &&
builtin echo "ble.sh: This is not an interactive session." >&3 || ((1))
return 1 2>/dev/null || builtin exit 1
fi
fi 3>&2 &>/dev/null # set -x 対策 #D0930
Expand Down
12 changes: 6 additions & 6 deletions docs/ChangeLog.md
Expand Up @@ -13,7 +13,7 @@
- edit (kill/copy): combine multiple kills and copies (suggested by 3ximus) `#D1443` 66564e1
- edit (`{kill,copy}-region-or`): fix unconditionally combined kills/copies (reported by 3ximus) `#D1447` 1631751
- canvas: update emoji database and support `bleopt emoji_version` (motivated by endorfina) `#D1454` d1f8c27
- emoji: unify emoji tables of different versions `#D1671` 0000000
- emoji: unify emoji tables of different versions `#D1671` af82662
- canvas, edit: support `bleopt info_display` (suggested by 0neGuyDev) `#D1458` 69228fa
- canvas (panel): always call `panel::render` to update height `#D1472` 51d2c05
- util (visible-bell): work around coordinate mismatches in subshells `#D1495` 01cfb10
Expand Down Expand Up @@ -67,15 +67,15 @@
- canvas (c2w:auto): work around combining chars applied to the previous line `#D1649` 1cbbecb
- canvas (c2w:auto): avoid duplicate requests `#D1649` 1cbbecb a3047f56
- canvas (c2w:auto): send <kbd>DSR(6)</kbd> in the internal state `#D1664` a3047f5
- canvas (c2w): support `bleopt char_width_mode=musl` `#D1668` 05b258f `#D1672` 0000000
- canvas (c2w): support `bleopt char_width_mode=musl` `#D1668` 05b258f `#D1672` af82662
- canvas (c2w:auto): detect `emacs` and `musl` `#D1668` 05b258f
- rlfunc: support vi word operations in `emacs` keymap (requested by SolarAquarion) `#D1624` 21d636a
- edit: support `TMOUT` for the session timeout `#D1631` 0e16dbd
- edit: support bash-5.2 `READLINE_ARGUMENT` `#D1638` d347fb3
- complete: support `complete [-DI]` in old versions of Bash through `_DefaultCmD_` and `_InitialWorD_` `#D1639` 925b2cd
- rlfunc: support nsearch widgets in `vi_nmap` keymap (requested by cornfeedhobo) `#D1651` 9a7c8b1
- prompt: support `bleopt prompt_ruler` (motivated by Barbarossa93) `#D1666` 05cf638
- prompt: fix hanging by a zero-width `prompt_ruler` `#D1673` 0000000
- prompt: fix hanging by a zero-width `prompt_ruler` `#D1673` 9033f29

## Changes

Expand Down Expand Up @@ -113,7 +113,7 @@
- Makefile: work around the case the repository is cloned without `--recursive` `#D1655` 22ace5f
- repo: add subdirectories `make` and `docs` `#D1657` 75bd04c
- util: time out <kbd>CPR</kbd> requests `#D1669` 1481d48
- main: suppress non-interactive session warnings also for `.bash_profile` (motivated by andreclerigo) `#D1676` 0000000
- main: suppress non-interactive warnings from manually sourced startup files (reported by andreclerigo) `#D1676` 0525528 0000000

## Fixes

Expand Down Expand Up @@ -183,7 +183,7 @@
## Documentation

- blerc: add all the missing options `#D1667` 0228d76
- blerc: add missing faces `argument_option` and `cmdinfo_cd_cdpath` (reported by Prikalel) `#D1675` 0000000
- blerc: add missing faces `argument_option` and `cmdinfo_cd_cdpath` (reported by Prikalel) `#D1675` 26aaf87

## Optimization

Expand Down Expand Up @@ -224,7 +224,7 @@
- term: disable `modifyOtherKeys` and do not send `DA2` for `st` (requested by Shahabaz-Bagwan) `#D1632` 92c7b26
- cmap: add `st`-specific escape sequences for cursor keys `#D1633` acfb879
- cmap: distinguish <kbd>find</kbd>/<kbd>select</kbd> from <kbd>home</kbd>/<kbd>end</kbd> for openSUSE `inputrc.keys` (reported by cornfeedhobo) `#D1648` c4d28f4
- cmap: freeze the internal codes of <kbd>find</kbd>/<kbd>select</kbd> and kitty special keys `#D1674` 0000000
- cmap: freeze the internal codes of <kbd>find</kbd>/<kbd>select</kbd> and kitty special keys `#D1674` fdfe62a
- main: work around self-modifying `PROMPT_COMMAND` by `bash-preexec` (reported by cornfeedhobo) `#D1650` 39ebf53
- decode: work around openSUSE broken `/etc/inputrc` `#D1662` e5b0c86

Expand Down
37 changes: 37 additions & 0 deletions note.txt
Expand Up @@ -5456,6 +5456,43 @@ bash_tips
bash_profile なので bashrc であると検出できなくてメッセージが表示されている。
何れにしても non-interactive session で読み込もうとしているのがいけないといえば行けない。

→推測で修正してみたが直っていないそうだ。画面を見ると原因が分かった。GDM
が Xsession を source して、 Xsession が /etc/profile 経由で .bashrc を呼び
出しているという事の様だ。つまり、non-interactive script が source .bashrc
をしている可能性を考慮に入れなければならない。この場合には、どう対処するべ
きか。

a warning を表示するというのは違う気がする。ユーザーは [[ $- == *i* ]] を考
慮に入れて bashrc を記述する事を要求されているのである。なので、ble.sh を
source する時にユーザー側で [[ $- == *i* ]] をチェックするか、或いは
ble.sh 自身でも *i* をチェックして silent に return するというのは妥当で
ある。

b 或いは warning は全く表示しないという可能性? しかし、直接 bash ble.sh を
実行された場合や、まるでライブラリであるかの様にプログラムから直接 source
ble.sh を実行した場合などは、明らかに使い方を間違えているのだから warning
を表示しても良い気がする。

c profile, bashrc など経由で ble.sh が source した時には、それが
non-interactive であっても警告は表示しない様にする。何しろ、profile,
bashrc は interactive でも non-interactive でも source され得るのだから、
non-interactive であったとしても使い方を間違えているとまでは言い難い。

Bash が source する可能性があるのは以下である。

- /etc/profile
- ~/.bashrc
- ~/.bash_profile
- ~/.profile

/etc/bashrc などはその他のファイルから呼び出されるので、これらはチェック
しなくても良い? と思ったが、もしかすると何らかのスクリプトが直接 source
/etc/bashrc みたいな事をしている可能性も考えられる。という事を考えると
bashrc も除外リストに入れて置いた方が良いのではないかという気もする。うー
ん。やはり除外リストに入れる事にする。

- /etc/bashrc

2021-10-04

* blerc: 含まれていない face が存在する (reported by Prikalel) [#D1675]
Expand Down

0 comments on commit 88e2df5

Please sign in to comment.