Skip to main content
added 4 characters in body
Source Link
Sildoreth
  • 2k
  • 8
  • 25
  • 42

The solution is to check whether input is coming from a tty device. First, check whether args were given, then check tty.

if [ ! "$#" -gt 0 ] && tty -s ; then show_help exit 1 fi 

From the documentation for tty:

Print the file name of the terminal connected to standard input.

If there isn't a fileterminal connected to standard input, tty gives a failure exit status. And the -s option suppresses output.

The solution is to check whether input is coming from a tty device. First, check whether args were given, then check tty.

if [ ! "$#" -gt 0 ] && tty -s ; then show_help exit 1 fi 

From the documentation for tty:

Print the file name of the terminal connected to standard input.

If there isn't a file connected to standard input, tty gives a failure exit status. And the -s option suppresses output.

The solution is to check whether input is coming from a tty device. First, check whether args were given, then check tty.

if [ ! "$#" -gt 0 ] && tty -s ; then show_help exit 1 fi 

From the documentation for tty:

Print the file name of the terminal connected to standard input.

If there isn't a terminal connected to standard input, tty gives a failure exit status. And the -s option suppresses output.

Source Link
Sildoreth
  • 2k
  • 8
  • 25
  • 42

The solution is to check whether input is coming from a tty device. First, check whether args were given, then check tty.

if [ ! "$#" -gt 0 ] && tty -s ; then show_help exit 1 fi 

From the documentation for tty:

Print the file name of the terminal connected to standard input.

If there isn't a file connected to standard input, tty gives a failure exit status. And the -s option suppresses output.