reinstall/ttys.sh

27 lines
651 B
Bash
Raw Normal View History

2023-08-08 23:21:28 +08:00
#!/bin/sh
prefix=$1
2023-09-03 19:35:01 +08:00
2023-10-08 21:58:16 +08:00
is_in_windows() {
[ "$(uname -o)" = Cygwin ] || [ "$(uname -o)" = Msys ]
}
2023-09-03 19:35:01 +08:00
2023-10-08 21:58:16 +08:00
# 最后一个 tty 是主 tty显示的信息最全
2023-09-03 19:35:01 +08:00
is_first=true
2023-10-27 12:09:45 +08:00
for tty in ttyS0 ttyAMA0 tty0; do
2023-10-08 21:58:16 +08:00
# hytron 有ttyS0 但无法写入
# cygwin 没有 tty0所以 windows 下 tty0 免检
if { [ "$tty" = tty0 ] && is_in_windows; } || stty -g -F "/dev/$tty" >/dev/null 2>&1; then
if $is_first; then
is_first=false
else
2023-09-03 19:35:01 +08:00
printf " "
fi
printf "%s" "$prefix$tty"
if [ "$prefix" = "console=" ] && [ "$tty" = ttyS0 ]; then
printf ",115200n8"
2023-08-08 23:21:28 +08:00
fi
fi
done