You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if [[ !-t 1 ]];thenecho"STDOUT not attached to a TTY">&2fi# if [[ -p /dev/stdout ]]; then# echo "STDOUT attached to a pipe" >&2# fi# if [[ ! -t 1 && ! -p /dev/stdout ]]; then# echo "STDOUT attached to a redirection" >&2# fiif [[ !-t 0 ]];thenecho"STDIN not attached to a TTY">&2fi# TODO: Hangs if stdin is empty?# echo -e "\tifne"# ifne -n echo "STDIN empty"
combined with
echo"============================================================"echo"No plumbing"echo"============================================================"
./stdio.sh
echo"============================================================"echo"Pipe to stdin"echo"============================================================"echo"foo from stdin"| ./stdio.sh
echo"============================================================"echo"Heredoc to stdin"echo"============================================================"
./stdio.sh <<EOF foo from heredocEOFecho"============================================================"echo"Pipe from stdout"echo"============================================================"
./stdio.sh | cat
echo"============================================================"echo"Redirect from stdout"echo"============================================================"
./stdio.sh >/dev/null
echo"============================================================"echo"Redirect from stdout to stdout"echo"============================================================"
./stdio.sh >/dev/stdout
./stdio.sh >/dev/tty
gives
============================================================
No plumbing
============================================================
============================================================
Pipe to stdin
============================================================
STDIN not attached to a TTY
============================================================
Heredoc to stdin
============================================================
STDIN not attached to a TTY
============================================================
Pipe from stdout
============================================================
STDOUT not attached to a TTY
============================================================
Redirect from stdout
============================================================
STDOUT not attached to a TTY
============================================================
Redirect from stdout to stdout
============================================================
The text was updated successfully, but these errors were encountered:
combined with
gives
The text was updated successfully, but these errors were encountered: