views:

119

answers:

2

I've just found out that getopt is not cross-platform (in particular for FreeBSD and Linux). What is the best workaround for this issue?

A: 

Basic syntax for getopt is cross-platform.

getopt vi: -v -i 100 file
codeholic
+2  A: 

Use getopts (with an "s").

According to Bash FAQ 35:

Never use getopt(1). getopt cannot handle empty arguments strings, or arguments with embedded whitespace. Please forget that it ever existed.

The POSIX shell (and others) offer getopts which is safe to use instead.

Dennis Williamson