🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #70

optarg(1) and quoted args, help wanted.

#70
From: Stephen Riehm
Date: Fri, 23 Oct 1992 13:43
31 lines
1700 bytes
Hi netters,

I am trying to use getopt(1) in some /bin/sh scripts to parse the
command line options, it works fine, except I want to get around
something that we are warned against in the manpage, namely embedded
blanks in args.

for example:
command -abc 'comment which might be long' -de file ...

How can I reliably catch the comment, The problem being that the
comment gets split into individual words in the course of the param
processing, and there seems to be no way to maintain the grouping.

I have toyed with the idea of the -c being the last option before the
file list, then I can just grab all the words until I get to a '--',
but then I break the one golden rule of getopt, options can come in
any order.

Any of you guys out there toyed with this?? if you did, did you find a
solution?? (having the comment appear after the options is also no
good because there's an implicit file list there!)

many thanks in advance

-----------------------------------------------------------------
Stephen Riehm		Configuration Management	   _-_|\ 
smr@pki-nbg.philips.de	Philips Kommunikations Industrie  /     \
Work: +49 911 526 2975	N|rnberg, Germany		  \_.-.*/
Fax:  +49 911 526 2095	"I was there, now I am here!"	       v 
"My company speaks another language, I CAN'T speak on its' behalf"
Technical Details
Message-ID: <smr.719847792@hitkw14>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!pki-nbg!hitkw14!smr

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!pki-nbg!hitkw14!smr
From: smr@pki-nbg.philips.de (Stephen Riehm)
Newsgroups: comp.unix.shell,comp.unix.programmer,comp.unix.wizards
Subject: optarg(1) and quoted args, help wanted.
Message-ID: <smr.719847792@hitkw14>
Date: 23 Oct 92 13:43:12 GMT
Sender: news@pki-nbg.philips.de
Reply-To: smr@pki-nbg.philips.de
Lines: 31