Skip to content

Commit

Permalink
main: check "/dev/tty" on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jul 28, 2022
1 parent 359a389 commit 19fa092
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ble.pp
Expand Up @@ -66,16 +66,17 @@
" We recommend using ble.sh with a release version of Bash." >&2 ;;
esac

if [[ $- != *i* ]]; then
if ((BASH_SUBSHELL)); then
builtin echo "ble.sh: ble.sh cannot be loaded into a subshell." >&2
return 1 2>/dev/null || builtin exit 1
elif [[ $- != *i* ]]; then
case " ${BASH_SOURCE[*]##*/} " in
(*' .bashrc '* | *' .bash_profile '* | *' .profile '* | *' bashrc '* | *' profile '*) false ;;
esac &&
builtin echo "ble.sh: This is not an interactive session." >&2 || ((1))
return 1 2>/dev/null || exit 1
fi

if ((BASH_SUBSHELL)); then
builtin echo "ble.sh: ble.sh cannot be loaded into a subshell." >&2
return 1 2>/dev/null || builtin exit 1
elif ! [[ -t 0 && -t 1 ]]; then
builtin echo "ble.sh: cannot find the correct TTY/PTY in this session." >&2
return 1 2>/dev/null || builtin exit 1
fi

Expand Down

0 comments on commit 19fa092

Please sign in to comment.