Previous: , Up: Invoking m4   [Contents][Index]

2.6 Specifying input files on the command line

The remaining arguments on the command line are taken to be input file names. If no names are present, standard input is read. A file name of - is taken to mean standard input. It is conventional, but not required, for input files to end in ‘.m4’.

The input files are read in the sequence given. Standard input can be read more than once, so the file name - may appear multiple times on the command line; this makes a difference when input is from a terminal or other special file type. It is an error if an input file ends in the middle of argument collection, a comment, or a quoted string.

The options --define (-D), --undefine (-U), --synclines (-s), and --trace (-t) only take effect after processing input from any file names that occur earlier on the command line. For example, assume the file foo contains:

$ cat foo

The text ‘bar’ can then be redefined over multiple uses of foo:

$ m4 -Dbar=hello foo -Dbar=world foo

If none of the input files invoked m4exit (see M4exit), the exit status of m4 will be 0 for success, 1 for general failure (such as problems with reading an input file), and 63 for version mismatch (see Using frozen files).

If you need to read a file whose name starts with a -, you can specify it as ‘./-file’, or use -- to mark the end of options.