Search code examples
solarisgetopt

getopt on linux and solaris


On linux the following operation with getopt works fine:

TEMP=`getopt :mvfuhr:: --long "mask,verbose,force,unmask, help, remask::" -n  'test.sh' -- "$@"`

On Solaris, i am unable use the long arguments to process... Though the this works:

  TEMP=`getopt :mvfuhr:: "$@"`

Looks like the getopt bundled with the solaris is of an older version. How can i make it work like linux? or is there some setting that needs to be done to process long arguments?


Solution

  • Here is a clever (although currently with a minor bug) way to handle this issue:

    Using getopts in bash shell script to get long and short command line options