Re: Writing a unix command prompt



On 2006-01-29, Barry Margolin wrote:
> In article <1O3Df.215188$D47.8103@xxxxxxxxxxxxxxxxxxxxxxxxx>,
> Robert Harris <robert.f.harris@xxxxxxxxxxxxxxxx> wrote:
>
>> repairman2003@xxxxxxxxx wrote:
>> > I'm writing a command prompt for unix and I've run into some problems:
>> >
>> > [snip]
>> >
>> > The problems
>> > 1. The workaround listed above.
>> > 2. One argument commands work fine but multiple doesn't. Eg. ls -a
>> > works fine, ls -al works fine but ls -a -l doesn't work. Any
>> > subsequent commands that don't have arguments don't work either, eg.
>> > ls works, then ls -a works, but ls again doesn't work.
>> >
>> > Any help is greatly appriciated!
>> use getopt(3) to parse your command line.
>
> getopt() is something that can be used in the program that gets
> executed, it has nothing to do with parsing by the shell itself.

You can feed any array to getopt. The command line just has to be
parsed into an array first.

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.