[linux-l] Re: Mac und Linux

Axel Weiß aweiss at informatik.hu-berlin.de
Do Aug 3 22:19:52 CEST 2006


Rocco Rutte wrote:
> >S.o. unter dem Debian ist das "-l" am Ende auch als ein switch
> > interpretiert, nicht nur wenn er vor den Dateinamen kommt.
>
> Ich weiss. Weil getopt() umsortiert.

Hi, ich misch mich mal ein ;)

$man getopt.3
# ...
By default, getopt() permutes the contents of argv as it scans, so that 
eventually all the  non-options  are at  the end.  Two other modes are also 
implemented.  If the first character of optstring is '+' or the environment 
variable POSIXLY_CORRECT is set, then option processing stops as soon as a  
non-option  argument  is encountered.  If the first character of optstring is 
'-', then each non-option argv-element is handled as if it were the argument 
of an option with character code 1.  (This is used by programs  that  were  
written  to expect  options and other argv-elements in any order and that 
care about the ordering of the two.)  The special argument "--" forces an end 
of option-scanning regardless of the scanning mode.
# ...
$getopt -V
getopt (enhanced) 1.1.3

Man kann mit (gnu-)getopt() also generell steuern, ob die Argumente ihre 
Reihenfolge behalten oder nicht. Was mich persönlich an getopt() stört sind 
die globalen Variablen.

> Ja. Getopt() bietet mir zu wenig zusätzliche Funktionalität, als dass
> ich dafür eine neue Funktion benutzen möchte. Selber schreiben dauert
> auch nicht länger und ist auch nicht mehr Code. Dafür aber frei von
> solchen Nebeneffekten.

Genau.

Gruß,
			Axel




Mehr Informationen über die Mailingliste linux-l