Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing an application which I'd like to follow the "Unix way."

What should I program it to do in case it is called with no arguments (which makes no practical sense):

  • display an error message
  • display help, or
  • exit silently returning 0 considering the task specified (which is nothing to do) was successfully accomplished?
share|improve this question
up vote 8 down vote accepted

That depends what kinds of arguments your application expects. If it processes files, it's traditional to read from standard input and write to standard output if no arguments are specified (example: cat, tee, …). If the application has an interactive mode, start it if no arguments are specified (example: sh, ed). If the application expects an object to work on, show an error message and exit with a non-zero status (example: cp, rm). If the application expects a command, show a usage message and exit with a non-zero status (example: sed, tar).

share|improve this answer

Most common variants:

  • display short version of application help with clause "To view full help type app-name --help";

  • display credits and license;

  • "error: no operation specified (use -h for help)".

share|improve this answer
If the program can read from standard input (something most Unix CLI commands can do), it's also acceptable to simply wait for input. For instance, cat will do this. – James Sneeringer Apr 9 '12 at 17:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.