| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
HISTFILE=A.txt |
| 4 |
IGNOREEOF=9999 |
| 5 |
|
| 6 |
bleopt_openat_base=33 |
| 7 |
source out/ble.sh --noattach |
| 8 |
|
| 9 |
# p 自分で設置したパイプを使ってみる |
| 10 |
# f 自分で作った通常ファイルを使ってみる |
| 11 |
# r 自分で stdout.off の内部でやっているリダイレクトを実行してみる |
| 12 |
test_flags= |
| 13 |
|
| 14 |
pipe1= |
| 15 |
if [[ $test_flags == *p* ]]; then |
| 16 |
ble/bin/rm -f memo/D0857/D0857.pipe |
| 17 |
ble/bin/mkfifo memo/D0857/D0857.pipe |
| 18 |
pipe_file=memo/D0857/D0857.pipe |
| 19 |
{ |
| 20 |
{ |
| 21 |
while IFS= builtin read -r line; do |
| 22 |
echo "[pipe] $line" >> memo/D0857/D0857.stderr |
| 23 |
done < "$pipe_file" |
| 24 |
} &>/dev/null & disown |
| 25 |
} &>/dev/null |
| 26 |
ble/util/openat pipe1 '> "$pipe_file"' |
| 27 |
echo "pipe1=$pipe1" >&2 |
| 28 |
fi |
| 29 |
|
| 30 |
function ble-decode/.hook { |
| 31 |
if [[ :$test_flags: == *:[spfr]:* ]]; then |
| 32 |
ble-edit/bind/stdout.on |
| 33 |
else |
| 34 |
ble-decode/PROLOGUE |
| 35 |
fi |
| 36 |
|
| 37 |
local byte |
| 38 |
for byte; do |
| 39 |
case $byte in |
| 40 |
(20) echo C-t |
| 41 |
#ls -la /proc/self/fd/ |
| 42 |
exit ;; |
| 43 |
(4) echo C-d ;; |
| 44 |
(*) echo $byte;; |
| 45 |
esac |
| 46 |
done |
| 47 |
|
| 48 |
if [[ :$test_flags: == *:p:* ]]; then |
| 49 |
echo "pipe: $pipe_file (fd: $pipe1)" |
| 50 |
exec 1>>$_ble_edit_io_fname1 2>&$pipe1 |
| 51 |
elif [[ :$test_flags: == *:f:* ]]; then |
| 52 |
exec 1>>$_ble_edit_io_fname1 2>>memo/D0857/D0857.stderr |
| 53 |
elif [[ :$test_flags: == *:r:* ]]; then |
| 54 |
echo "pipe: $_ble_edit_io_fname2.pipe (fd: $_ble_edit_fd_stderr_pipe)" |
| 55 |
exec 1>>$_ble_edit_io_fname1 2>&$_ble_edit_fd_stderr_pipe |
| 56 |
elif [[ :$test_flags: == *:s:* ]]; then |
| 57 |
ble-edit/bind/stdout.off |
| 58 |
else |
| 59 |
ble-decode/EPILOGUE |
| 60 |
fi |
| 61 |
} |
| 62 |
|
| 63 |
function ble-attach.1 { |
| 64 |
# 取り敢えずプロンプトを表示する |
| 65 |
ble/term/enter # 3ms (起動時のずれ防止の為 stty) |
| 66 |
ble-edit/initialize # 3ms |
| 67 |
ble-edit/attach # 0ms (_ble_edit_PS1 他の初期化) |
| 68 |
ble/textarea#redraw # 37ms |
| 69 |
ble/util/buffer.flush >&2 |
| 70 |
|
| 71 |
# keymap 初期化 |
| 72 |
IFS=$' \t\n' |
| 73 |
ble-decode/initialize # 7ms |
| 74 |
ble-decode/reset-default-keymap # 264ms (keymap/vi.sh) |
| 75 |
|
| 76 |
ble-decode/attach |
| 77 |
_ble_edit_detach_flag= # do not detach or exit |
| 78 |
|
| 79 |
ble-edit/reset-history # 27s for bash-3.0 |
| 80 |
|
| 81 |
ble-edit/info/default |
| 82 |
ble-edit/bind/.tail |
| 83 |
} |
| 84 |
|
| 85 |
function ble-attach.2 { |
| 86 |
source memo/D0857/D0857.bind # $_ble_base_cache/ble-decode-bind.$_ble_bash.UTF-8.bind |
| 87 |
_ble_term_state=internal |
| 88 |
} |
| 89 |
|
| 90 |
# ble-attach.2 |
| 91 |
# ble-attach.1 |
| 92 |
ble-attach |