if_stdin should use -t instead of -p

Issue #4 new
Michael Diamond
repo owner created an issue

See http://tldp.org/LDP/abs/html/fto.html and http://tldp.org/LDP/abs/html/intandnonint.html#II2TEST

Currently if_stdin doesn't handle redirections, just pipes, e.g.:

$ if_stdin "echo stdin" "echo nostdin"
nostdin

$ echo | if_stdin "echo stdin" "echo nostdin"
stdin

$ if_stdin "echo stdin" "echo nostdin" <<<''
nostdin

$ if_stdin "echo stdin" "echo nostdin" < /dev/null
nostdin

# Notice this counts as a pipe
$ if_stdin "echo stdin" "echo nostdin" < <(echo)
stdin

It might just be simplest to swap to -t, but need to make sure that doesn't cause issues elsewhere (e.g. TLDP suggests it doesn't play well with SSH, but I haven't been able to replicate that).

Comments (0)

  1. Log in to comment