There are some utilities that accept a
-- (double dash) as the signal for "end of options", required when a file name starts with a dash:
$ echo "Hello World!" >-file $ cat -- -file Hello World! $ cat -file # cat - -file fails in the same way. cat: invalid option -- 'f' Try 'cat --help' for more information.
But some of those utilities don't show such an option in the manual page.
man page for
cat doesn't document the use (or validity) of a
-- argument in any of the OS'es. This is not meant to be a Unix - Linux flame war, it is a valid, and, I believe, useful concern.
ed (and I am sure many others) document such an option in their manual page that I can find.
./-file is a more portable workaround to the use of
For example, the
source (dot) command (and written as
.) doesn't (generally) work well with an
$ echo 'echo "Hello World!"' >-file $ . ./-file Hello World! $ . -file ksh: .: -f: unknown option ksh: .: -i: unknown option ksh: .: -l: unknown option ksh: .: -e: unknown option Usage: . [ options ] name [arg ...] $ . -- -file # works in bash. Not in dash, ksh, zsh. ksh: .: -file: cannot open [No such file or directory]