🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4764

Re: Question on 'getopt'

#4764
From: Stan Ryckman
Date: Wed, 07 Feb 1996 03:49
47 lines
2038 bytes
In article <1996Feb5.225706.10082@tmai.com>,
Sridhar Panchapakesan  <sridharp> wrote:
:This is a multi-part message in MIME format.

If you can avoid posting in MIME, please do so.  Some can't read it.
Also, your post doesn't have a replyable email address.  Seems like
you could use some new software.

[snip]

:I am trying to use 'getopt' to read a quoted string as options for a
:program. It works fine when I try it from a shell (csh) but when I try
:running it from a script using 'exec' it does not accept the entire the
:entire quoted string as the option.
:
:e.g. ( test is the program name)
:% test -f "-g -o 5" in.txt
:( getopt works fine. The string "-g -o 5" is read correctly into
:optargs. Note that I have to use '-' (dash) in the string as a
:requirement of the program itself.)
:
:However when I try it from the script file:
:
:exec test -f "\"-g -o 5\"" in.txt
:
:The getopt only recognizes "-g as the option for -f instead of "-g -o
:5".
:
:I would appreciate any help in this area..

Well, since it works fine in the first case, you don't seem to have a
C problem but rather a shell problem.  Maybe you couldn't tell that,
so I won't flame you.  (This time :-)

I would suggest you try comp.unix.shell.  Also, give them the
results of the "uname -a" command in case it's a system-related thing.
Other: they will probably tell you to use sh scripts, not csh, because
csh is buggy.  They will be right.  Also, try to use some other name
than "test" since "test" is a UNIX command and that possibility adds
to the confusion.

Good luck.  Now back to C standards issues (we hope).

Cheers,
Stan.
--
Stan Ryckman  (stanr@tiac.net) (new e-mail address)
Technical Details
Message-ID: <4f97fs$s47@sundog.tiac.net>
Path: arc1-ca.pugleaf.net!sundog.tiac.net!stanr
References: <1996Feb5.225706.10082@tmai.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sundog.tiac.net!stanr
From: stanr@tiac.net (Stan Ryckman)
Newsgroups: comp.std.c
Subject: Re: Question on 'getopt'
Date: 7 Feb 1996 03:49:16 GMT
Organization: Amber & Sneakers Fan Club
Message-ID: <4f97fs$s47@sundog.tiac.net>
References: <1996Feb5.225706.10082@tmai.com>
NNTP-Posting-Host: sunspot.tiac.net