Go to the previous, next section.
Please don't make the behavior of a utility depend on the name used to invoke it. It is useful sometimes to make a link to a utility with a different name, and that should not change what it does.
Instead, use a run time option or a compilation switch or both to select among the alternate behaviors.
Likewise, please don't make the behavior of the program depend on the type of output device it is used with. Device independence is an important principle of the system's design; do not compromise it merely to save someone from typing an option now and then.
If you think one behavior is most useful when the output is to a terminal, and another is most useful when the output is a file or a pipe, then it is usually best to make the default behavior the one that is useful with output to a terminal, and have an option for the other behavior.
Compatibility requires certain programs to depend on the type of output
device. It would be disastrous if ls
or sh
did not do so
in the way all users expect. In some of these cases, we supplement the
program with a preferred alternate version that does not depend on the
output device type. For example, we provide a dir
program much
like ls
except that its default output format is always
multi-column format.
It is a good idea to follow the POSIX guidelines for the
command-line options of a program. The easiest way to do this is to use
getopt
to parse them. Note that the GNU version of getopt
will normally permit options anywhere among the arguments unless the
special argument `--' is used. This is not what POSIX
specifies; it is a GNU extension.
Please define long-named options that are equivalent to the
single-letter Unix-style options. We hope to make GNU more user
friendly this way. This is easy to do with the GNU function
getopt_long
.
One of the advantages of long-named options is that they can be consistent from program to program. For example, users should be able to expect the "verbose" option of any GNU program which has one, to be spelled precisely `--verbose'. To achieve this uniformity, look at the table of common long-option names when you choose the option names for your program. The table appears below.
If you use names not already in the table, please send `gnu@prep.ai.mit.edu' a list of them, with their meanings, so we can update the table.
It is usually a good idea for file names given as ordinary arguments to be input files only; any output files would be specified using options (preferably `-o'). Even if you allow an output file name as an ordinary argument for compatibility, try to provide a suitable option as well. This will lead to more consistency among GNU utilities, so that there are fewer idiosyncracies for users to remember.
Programs should support an option `--version' which prints the program's version number on standard output and exits successfully, and an option `--help' which prints option usage information on standard output and exits successfully. These options should inhibit the normal function of the command; they should do nothing except print the requested information.
recode
.
ptx
.
tar
.
du
, ls
, nm
, stty
, uname
,
and unexpand
.
diff
.
ls
.
etags
, tee
, time
;
`-r' in tar
.
cp
.
m4
.
diff
.
tac
.
cpio
and diff
.
cpio
and tar
.
head
and tail
.
ptx
.
head
, split
, and tail
.
etags
.
tar
.
chgrp
and chown
.
ls
.
recode
.
su
;
`-x' in GDB.
tar
.
tar
.
tar
.
tar
.
diff
.
ptx
and recode
.
who
.
du
.
tar
and cpio
.
etags
.
touch
.
m4
;
`-t' in Bison.
m4
.
etags
.
tar
.
chgrp
, chown
, cpio
, du
,
ls
, and tar
.
du
.
recode
.
look
.
tar
.
csplit
.
ls
, it
means to show directories themselves rather than their contents. In
rm
and ln
, it means to not treat links to directories
specially.
strip
.
strip
.
m4
.
diff
.
csplit
.
diff
.
xargs
.
m4
.
ls
.
tar
.
xargs
.
diff
.
sed
.
nm
.
cpio
;
`-x' in tar
.
finger
.
su
.
info
, Make, mt
, and tar
;
`-n' in sed
;
`-r' in touch
.
ls
.
tar
.
ptx
.
tail
.
cp
, ln
, mv
, and rm
.
ls
, time
, and ptx
.
etags
.
ptx
.
tar
.
ul
.
recode
.
install
.
tar
.
m4
.
objdump
and recode
who
.
ls
.
who
.
diff
.
ls
;
`-x' in recode
.
diff
.
ls
.
diff
.
look
and ptx
;
`-i' in diff
.
ptx
.
etags
.
tee
.
diff
.
diff
.
tar
.
etags
;
`-I' in m4
.
tar
.
expand
.
diff
.
ls
.
cp
, ln
, mv
, rm
;
`-e' in m4
;
`-p' in xargs
;
`-w' in tar
.
csplit
.
du
and ls
.
split
.
split
, head
, and tail
.
cpio
.
cpio
;
`-l' in recode
.
tar
.
ls
.
su
.
gnu@prep.ai.mit.edu
.
ptx
.
hello
and uname
.
cpio
.
xargs
.
xargs
.
xargs
.
xargs
.
who
.
who
.
diff
.
install
, mkdir
, and mkfifo
.
tar
.
tar
.
touch
.
etags
.
cp
.
gprof
.
nm
.
gprof
.
gprof
.
info
.
uname
.
cpio
.
objdump
.
xargs
.
cat
.
cat
.
nm
.
cpio
and ls
.
tar
.
tar
, cp
, and du
.
ptx
.
gprof
.
gprof
.
rm
.
install
.
diff
.
mkdir
and rmdir
.
ul
.
cpio
.
finger
.
cpio
and tar
.
m4
.
csplit
.
tar
and cp
.
su
.
cpio
.
tar
.
tar
.
diff
.
cmp
.
nm
.
nm
.
ls
.
diff
.
tar
.
tar
.
chgrp
, chown
, cp
, ls
, diff
,
and rm
.
ptx
.
tac
.
uname
.
objdump
.
cpio
.
xargs
.
diff
.
cpio
.
ls
and nm
.
diff
.
ptx
.
tar
.
tar
.
stty
.
ptx
.
du
.
tac
.
recode
to chose files or pipes for sequencing passes.
su
.
cat
.
diff
.
cat
.
diff
.
cat
.
ls
.
ls
.
tar
.
diff
.
cat
.
tar
and diff
to specify which file within
a directory to start processing with.
recode
.
install
.
strip
.
strip
.
cp
, ln
, mv
.
csplit
.
gprof
.
du
.
ln
.
objdump
.
m4
.
uname
.
expand
and unexpand
.
ls
.
tput
and ul
.
diff
.
ls
and touch
.
tar
.
du
.
ranlib
, and recode
.
m4
.
hello
;
`-G' in m4
and ptx
.
etags
.
etags
.
ptx
.
tar
.
cpio
.
m4
.
nm
.
cp
, `etags', `mv', `tar'.
tar
.
cp
, ln
, mv
.
etags
.
tar
.
ls
and ptx
.
ptx
.
who
.
gprof
.
Go to the previous, next section.