Skip to content

Commit

Permalink
main: fix the check of tty on stdin/stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jul 8, 2022
1 parent 5111323 commit 80f09c9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ble.pp
Expand Up @@ -149,14 +149,14 @@ function ble/debug/measure-set-timeformat {
elif [[ $- != *i* ]]; then
case " ${BASH_SOURCE[*]##*/} " in
(*' .bashrc '* | *' .bash_profile '* | *' .profile '* | *' bashrc '* | *' profile '*) false ;;
esac &&
esac &&
builtin echo "ble.sh: This is not an interactive session." >&3 || ((1))
return 1 2>/dev/null || builtin exit 1
elif ! [[ -t 0 && -t 1 ]] && ! ((1)) >/dev/tty; then
elif ! [[ -t 4 && -t 5 ]] && ! ((1)) >/dev/tty; then
builtin echo "ble.sh: cannot find a controlling TTY/PTY in this session." >&3
return 1 2>/dev/null || builtin exit 1
fi
fi 3>&2 &>/dev/null # set -x 対策 #D0930
fi 3>&2 4<&0 5>&1 &>/dev/null # set -x 対策 #D0930

{
## @var _ble_bash_POSIXLY_CORRECT_adjusted
Expand Down
3 changes: 2 additions & 1 deletion docs/ChangeLog.md
Expand Up @@ -352,11 +352,12 @@
- main: force prompt-attach inside the nix-shell `rc` `#D1766` ceb2e7c
- canvas: test the terminal for the sequence of clearing `DECSTBM` `#D1748` 4b1601d
- main: check `/dev/tty` on startup (reported by andychu) `#D1749` 711c69f
- main: fix the check of tty on stdin/stdout `#D1833` XXXXXXX
- util: add identification of Windows Terminal `wt` `#D1758` e332dc5
- complete: evaluate words for `noquote` (motivated by SuperSandro2000) `#D1767` 0a42299
- edit (TRAPDEBUG): preserve original `DEBUG` trap and enabled it in `PROMPT_COMMAND` (motivated by ammarooo) `#D1772` `#D1773` ec2a67a
- main, trap: fix initialization order of `{save,restore}-BASH_REMATCH` (reported by SuperSandro2000) `#D1780` 689534d
- global: work around bash-3.0 bug that single quotas remains for `"${v-$''}"` `#D1774` 9b96578
- global: work around bash-3.0 bug that single quotes remains for `"${v-$''}"` `#D1774` 9b96578
- util: work around old `vte` not supporting `DECSCUSR` yet setting `TERM=xterm` (reported by dongxi8) `#D1785` 70277d0
- progcomp: work around the cobra V2 description hack (reported by SuperSandro2000) `#D1803` 71d0736
- complete: work around blocking `_scp_remote_files` and `_dnf` (reported by iantra) `#D1807` a4a779e 46f5c13
Expand Down
33 changes: 33 additions & 0 deletions note.txt
Expand Up @@ -1821,6 +1821,29 @@ bash_tips
- Acknowledgments
- keymap の移動 (これは別 commit にする?)

2022-07-08

* redirection も word-splitting の対象である。今まで数字は空白でないから大丈
夫と考えていたが IFS に数字が含まれている可能性もある。ble.sh は内部では
IFS を調整しているとは言え、ユーザーから呼び出した場合なども考えると一律で
ちゃんと quote する様にするべき。

grc '[<>]&\$'

実は $(()) も同様である。現状では $(()) は数字だから quote しなくて良いと考
えて裸で記述しているが、やはり任意の IFS の可能性を考えると quote するべき
である。これは物凄く沢山ある。

grc ' \$\(\('

2022-07-06

* syntax: "function word1 word2 word3 word4()"

word1 がオプション形式の場合何故か word2 まで関数名として認識される。word3
に対して type が走ってエラーメッセージが表示されて表示が乱れる。文法構造が
一体どういう事になっているのか確認する必要がある。

2022-07-04

* [保留] debug_xtrace を bash-4.0 以下でも対応する?
Expand Down Expand Up @@ -6453,6 +6476,16 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2022-07-07

* main: fd 0, 1 が TTY かどうかのチェックが常に偽になっている [#D1833]
Ref #D1749

ble-0.3 に 711c69f (#D1749) を backport している途中に気づいた。今までは
/dev/tty もチェックしていたので、このチェックに失敗しても問題が表面化してい
なかっただけ。ble-0.3 で /dev/tty のチェックをスキップする様にしたら問題が
表面化した。ble-0.3 に対して行ったのと同じ修正を適用する。

2022-07-06

* main, decode: ble-attach & set -e [#D1832]
Expand Down
2 changes: 1 addition & 1 deletion src/edit.sh
Expand Up @@ -757,7 +757,7 @@ _ble_prompt_term_status_data=()
## @var[out] DRAW_BUFF[]
## 出力先の配列です。
function ble/prompt/print {
local ret=$1 a b
local ret=$1
[[ $prompt_noesc ]] ||
ble/string#escape-characters "$ret" '\$"`'
ble/canvas/put.draw "$ret"
Expand Down

0 comments on commit 80f09c9

Please sign in to comment.