# why not gnu-style command line arguments?



## fluca1978 (Jul 1, 2011)

Hi all,

I admit this is a newbie question, and first of all allow me to say I love FreeBSD and I'm comfortable with it as it is. However when I show FreeBSD to my Linux colleagues I often am asked about why the need for such basic userland commands that do not accept the _flexible_ syntax as GNU/Linux commands do. I mean, in several GNU/Linux commands you can specify options almost in every position of the command line, while in similar commands in FreeBSD you cannot. I suspect this is due to the adoption of the gnuopts library, but I'd like to know if there is a rationale behind this choice in order to be able to convince more Linux users!

Thanks


----------



## SirDice (Jul 1, 2011)

There's a simple explanation for that: history. Keep in mind that the utilities that come with FreeBSD pre-date the Linux/GNU ones by about 2 decades.


----------



## fonz (Jul 1, 2011)

fluca1978 said:
			
		

> why the need for such basic userland commands


Basic is good. It's fast and efficient. Basic is nice. 

Fonz (that's basic, not BASIC...)


----------



## wblock@ (Jul 1, 2011)

fluca1978 said:
			
		

> I mean, in several GNU/Linux commands you can specify options almost in every position of the command line, while in similar commands in FreeBSD you cannot.



Could you give an example?


----------



## graudeejs (Jul 1, 2011)

wblock said:
			
		

> Could you give an example?



In Linux this is valid, but not in BSD: `$ ls /some/path -d`

Coming from Linux it was hard to get used to this. Even now and then when I write *chmod killasmurf86:killasmurf86* I need to return to space after *chmod* to add *-R* flag that I forgot


----------



## Zare (Jul 1, 2011)

That would imply that getopt(3) call from BSD libc doesn't support such feature, which is non-sense.


----------



## Zare (Jul 1, 2011)

Those commands expect main argument to reside in _argv[argc - 1]_. First the options then the main argument. That's called standardization.


----------



## UNIXgod (Jul 2, 2011)

GNU software tends to be a bit bloated and less optimized than it's BSD and UNIX counterparts. It was actually done for legal reasons to make obvious the gnu software was a clone and not a infringed copy. From their coding guidelines:

http://www.gnu.org/prep/standards/standards.html#Reading-Non_002dFree-Code



> Unix utilities were generally optimized to minimize memory use; if you go for speed instead, your program will be very different. You could keep the entire input file in memory and scan it there instead of using stdio.



Explain to your Linux colleagues that writing portable code is more important than using the so-called extensions. Look at the link in my sig.

~


----------



## Martillo1 (Jul 9, 2011)

Well, maybe because GNU is Not Unix.


----------

