[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Adding groups to a user

Hash: SHA1

On 07/22/09 23:20, quoth Tony Nelson:
> On 09-07-22 22:51:23, Steven W. Orr wrote:
>> Right. There's a standard for how command options should work.
>> verb options arguments
>> That's why we have getopt and that's why I shudder when I see people
>> reinventing wheels.
>>From `man 3 getopt`:
>     "By  default,  getopt()  permutes  the  contents  of argv as it
>     scans, so that eventually all the non-options are at the end."
> So, the default "standard" is to allow mixed options and arguments.

That's why it's so important to do it correctly. Performing consistency
checking is also an important part of the job. For bash programming, I've
actually been using the builtin getopts. If you're in C code, I'd recommend
calling getopt with a + prefixing the first arg.

The main point is that people should design their command lines using POSIX or
SVR4 standards in the first place. Then the decision to use things like getopt
or getopts gets a lot easier.

Take a look at gcc as a classic example of how *not* to do it.

gcc --help # I'm good with that.
gcc -c # Also good. Let's make object code.
gcc -pipe # That's where you lose me. It's just a good thing they don't have a
 -p, -i or a -e option. Or wait! Maybe they can't now.

- --
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
Version: GnuPG v2.0.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]