Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Fucking getopts, how does it work?

Name: Anonymous 2010-09-27 6:15

Is getopts builtin in most shells?
I've been told that it should work fine in bsh, bash and ksh. Dunno about the BSD/GNU implementations.

I want it to parse something like this:
scriptname {0 or more directories} destinationdirectory
scriptname -c destinationdirectory
scriptname -v {o or more directories}
scriptname -i {0 or more directories} destinationdirectory



Is it possible to parse with getopts or should I do it "by hand"?

Thanks in advance for any tip or information on implementation.

Name: Anonymous 2010-09-27 7:39

How did I used the Interwebs to gather information?

Name: Anonymous 2010-09-27 9:47

GNU bash has getopts, don't care about the rest but probably at least zsh does too.

What you want to do is fairly simple though and you might find it easier to do it manually (just like breathing manually). And of course, you may want to use a real programming language like FIOC.

Name: Anonymous 2010-09-27 17:12

getopt is a possibility too

Name: Anonymous 2010-09-27 17:37

getopts is not a shell builtin, moron. It's a POSIX utility.

Name: Anonymous 2010-09-27 17:41

>>3
real programming language
FIOC
( ≖‿≖)

Name: Anonymous 2010-09-27 19:17

>>5
getopts is a bash builtin, moron. getopt(1) is the POSIX utility.

Name: Anonymous 2010-09-27 20:04

>>6
Implying Turing-completeness isn't real
( ≖‿≖)

Name: Anonymous 2010-09-27 20:28

>>7
You're a fucking idiot. GNU bash implements getopts as a builtin for reasons of efficiency, but a POSIX system also has to provide it as a utility. Just the same as echo, printf, pwd, and all of those.

Name: Anonymous 2010-09-27 21:00

arguing about getopts
Oh lord.

Name: Anonymous 2010-09-27 21:58

>>3
yes, zsh has it

Name: Anonymous 2010-09-28 5:52

>>9
YHBT

Name: Anonymous 2010-09-28 6:33

>>1
It is possible, and I've heard that Google has plenty of examples, but I cannot check it myself for you. Please see his websight http://google.com/

>>9
Oh blindman!
getopt is POSIX utility, it is a part of libc with getopt.h.
getopts is a bash (zsh etc) builtin.

Name: Anonymous 2010-09-28 9:09

Use anonix getopts

Name: Anonymous 2010-09-28 9:58

>>14
Use anushax getopts

Name: Anonymous 2010-09-28 10:38

>>13
Are you going to keep repeating your bullshit in the hopes that someone will eventually believe you? getopt and getopts are both POSIX utilities, and you're a blithering buffoon.

Name: Anonymous 2010-09-28 10:44

>>16
Eat shit.

Name: Anonymous 2010-09-28 10:50

>>17
Polecat kebabs.

Name: Anonymous 2010-09-28 11:15

>>18
Fuck off, ``faggot''.

Name: Anonymous 2010-09-30 2:44

>>19
Here comes the imageboard paladin.

Name: Anonymous 2011-02-03 7:10

Name: Anonymous 2011-02-18 13:48

<-- check 'em

Name: Anonymous 2013-01-19 14:41

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List