Article View: mod.std.unix
Article #372Re: A convention for -file
From: Moderator, John Quarterman
Date: Mon, 03 Nov 1986 20:14
Date: Mon, 03 Nov 1986 20:14
46 lines
2417 bytes
2417 bytes
[ 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@ut-sally.UUCP> weemba@brahms.berkeley.edu (Matthew P Wiener)
writes:
> Date: Fri, 24 Oct 86 14:27:50 PDT
> Organization: University of California, Berkeley
>
> In article <6029@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
Technical Details
Message-ID:
<6212@ut-sally.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!std-unixReferences:
<6110@ut-sally.UUCP> <6029@ut-sally.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!std-unix From: std-unix@ut-sally.UUCP (Moderator, John Quarterman) Newsgroups: mod.std.unix Subject: Re: A convention for -file Message-ID: <6212@ut-sally.UUCP> Date: Mon, 3-Nov-86 15:14:39 EST Article-I.D.: ut-sally.6212 Posted: Mon Nov 3 15:14:39 1986 Date-Received: Tue, 4-Nov-86 02:28:18 EST References: <6110@ut-sally.UUCP> <6029@ut-sally.UUCP> Organization: IEEE P1003 Portable Operating System for Computer Environments Committee Lines: 46 Approved: jsq@sally.utexas.edu