A convention for -file
Moderator, John Quarterman
std-unix at ut-sally.UUCP
Tue Nov 4 06:14:39 AEST 1986
[ I'm not positive anything in this article has not been said before,
but it's a useful summary. -mod ]
From: nike!pyramid!pyrtech!trwrb!desint!geoff (Geoff Kuenning)
Date: Wed, 29 Oct 86 01:02:04 pst
Organization: SAH Consulting, Manhattan Beach, CA
In article <6110 at ut-sally.UUCP> weemba at brahms.berkeley.edu (Matthew P Wiener)
writes:
> Date: Fri, 24 Oct 86 14:27:50 PDT
> Organization: University of California, Berkeley
>
> In article <6029 at ut-sally.UUCP> Mark Horton writes:
> > Since many commands take names beginning with "-" as flags,
> > file names beginning with "-" don't always work.
>
> There's a real easy fix to the current random collection of special
> flags that handle filenames beginning with a dash: always interpret
> two dashes at the beginning of a command line argument as the name for
> the file obtained by eliding the two dashes into one. Thus
There're at least two reasons not to do this: (1) it's unnecessary, and
(2) it conflicts with the standard already established for getopt(3).
It's unnecessary because you can *always* specify a file beginning with
"-" as "./-file". I find this much easier to remember.
The second reason is that getopt(3) already explicitly defines an argument
of "--" as delimiting the end of the switches. It is provided specifically
to handle the case when an argument begins with a dash.
Thus, for example, to grep(1) for commands that take a "-i" switch, we
would use:
egrep -- -i /usr/man/u_man/man1/*
(Note that this applies only on System V; BSD uses an older convention.
Also note that some System V documentation incorrectly lists the obsolete
"-e" switch for this purpose; "-e" doesn't work, but "--" does.)
--
Geoff Kuenning
{hplabs,ihnp4}!trwrb!desint!geoff
Volume-Number: Volume 8, Number 27
More information about the Mod.std.unix
mailing list