9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] -- in rsc's g script
@ 2010-05-15 13:16 Rudolf Sykora
  2010-05-15 13:37 ` Steve Simon
  2010-05-15 13:41 ` Robert Ransom
  0 siblings, 2 replies; 7+ messages in thread
From: Rudolf Sykora @ 2010-05-15 13:16 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

could anybody tell me what's the meaning of '--' in

grep -n $flags -- $1 *.[Cbchm] /dev/null

?
This I found in Russ Cox's g script.

Thanks
Ruda



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] -- in rsc's g script
  2010-05-15 13:16 [9fans] -- in rsc's g script Rudolf Sykora
@ 2010-05-15 13:37 ` Steve Simon
  2010-05-15 18:50   ` Richard Miller
  2010-05-15 13:41 ` Robert Ransom
  1 sibling, 1 reply; 7+ messages in thread
From: Steve Simon @ 2010-05-15 13:37 UTC (permalink / raw)
  To: 9fans

see arg(2) for all the details.

-- indicates the end of any options, it ensures that any following
arguments which happen to begin with a minus are not interpreted
as options.

consider the classic question: "how do I remove a file called -z"

-Steve



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] -- in rsc's g script
  2010-05-15 13:16 [9fans] -- in rsc's g script Rudolf Sykora
  2010-05-15 13:37 ` Steve Simon
@ 2010-05-15 13:41 ` Robert Ransom
  2010-05-15 13:53   ` Rudolf Sykora
  1 sibling, 1 reply; 7+ messages in thread
From: Robert Ransom @ 2010-05-15 13:41 UTC (permalink / raw)
  To: 9fans

On Sat, 15 May 2010 15:16:35 +0200
Rudolf Sykora <rudolf.sykora@gmail.com> wrote:

> could anybody tell me what's the meaning of '--' in
>
> grep -n $flags -- $1 *.[Cbchm] /dev/null

'--' tells the Plan 9 program argument parser to stop looking for
options.  See arg(2).

GNU getopt has the same feature.

Robert Ransom



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] -- in rsc's g script
  2010-05-15 13:41 ` Robert Ransom
@ 2010-05-15 13:53   ` Rudolf Sykora
  2010-05-15 14:27     ` Steve Simon
  2010-05-15 18:44     ` erik quanstrom
  0 siblings, 2 replies; 7+ messages in thread
From: Rudolf Sykora @ 2010-05-15 13:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> '--' tells the Plan 9 program argument parser to stop looking for
> options.  See arg(2).

so is it a program dependent feature in the sence that I must know
which program uses arg(2) and which does not?
(E.g that grep uses it but some other command (is there any?) does not?)
Must I read the program's source or should it be documented in man
pages? -- there is nothing about this in the man page of grep...

Thanks
Ruda



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] -- in rsc's g script
  2010-05-15 13:53   ` Rudolf Sykora
@ 2010-05-15 14:27     ` Steve Simon
  2010-05-15 18:44     ` erik quanstrom
  1 sibling, 0 replies; 7+ messages in thread
From: Steve Simon @ 2010-05-15 14:27 UTC (permalink / raw)
  To: 9fans

I don't beleive greps manual page says it writes its output to file descriptor 1
and reaqds from file descriptor zero but it does, as do all conventional (sic)
plan9 programs. Similarly they all use arg(2) to parse their args so they will
all support --; however if you are unsure you could look at the source, yes.

-Steve



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] -- in rsc's g script
  2010-05-15 13:53   ` Rudolf Sykora
  2010-05-15 14:27     ` Steve Simon
@ 2010-05-15 18:44     ` erik quanstrom
  1 sibling, 0 replies; 7+ messages in thread
From: erik quanstrom @ 2010-05-15 18:44 UTC (permalink / raw)
  To: 9fans

On Sat May 15 09:54:25 EDT 2010, rudolf.sykora@gmail.com wrote:
> > '--' tells the Plan 9 program argument parser to stop looking for
> > options.  See arg(2).
>
> so is it a program dependent feature in the sence that I must know
> which program uses arg(2) and which does not?
> (E.g that grep uses it but some other command (is there any?) does not?)
> Must I read the program's source or should it be documented in man
> pages? -- there is nothing about this in the man page of grep...

for the record, grep also accepts -e which escapes the next option.

here's a list of all the single-file commands in /sys/src that don't
use ARGBEGIN/ARGEND.  compiling a comprehensive list is
an exercize left to the reader.  of course, only a hand full of
shell scripts use getflags and conform to the general convention.

- erik

---

 ; x=`{grep -l ARGBEGIN *.c}
; for(i in *.c) if (! ~ $i $x) echo $i
ar.c
awd.c
basename.c
cal.c
cat.c
chmod.c
clock.c
dd.c
echo.c
factor.c
fortune.c
getmap.c
html2ms.c
join.c
kbmap.c
kprof.c
lens.c
mc.c
msleep.c
mv.c
p.c
pbd.c
pr.c
pwd.c
sleep.c
sort.c
swap.c
tail.c
test.c
time.c
tprof.c
uniq.c
unlnfs.c
unmount.c
xd.c



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9fans] -- in rsc's g script
  2010-05-15 13:37 ` Steve Simon
@ 2010-05-15 18:50   ` Richard Miller
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Miller @ 2010-05-15 18:50 UTC (permalink / raw)
  To: 9fans

> consider the classic question: "how do I remove a file called -z"

rm ./-z




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-05-15 18:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-15 13:16 [9fans] -- in rsc's g script Rudolf Sykora
2010-05-15 13:37 ` Steve Simon
2010-05-15 18:50   ` Richard Miller
2010-05-15 13:41 ` Robert Ransom
2010-05-15 13:53   ` Rudolf Sykora
2010-05-15 14:27     ` Steve Simon
2010-05-15 18:44     ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).