3

In bash: I input the command:

getopt -l name,data -- --namd

and the output is

-- name,pp -- --namd

input :

getopt -l name,data -- --name

the output alse

-- name,pp -- --name

why it dosen't tell me the err when i input getopt -l name,data -- --namd?

soulmerge
  • 71,140
  • 18
  • 117
  • 149
qiushuitian
  • 1,191
  • 4
  • 17
  • 31

1 Answers1

7

The problem is that on the mac, getopt is the BSD based getopt, rather than the gnu-based getopt.

It doesn't understand long options. It's not that it 'doesn't work well', it's that it's not designed to do what you asked.

Petesh
  • 87,225
  • 3
  • 99
  • 116
  • Thanks. But if I want to deal with the long options, how can I do? Must I analyze the parameter myself? – qiushuitian Aug 03 '12 at 03:27
  • 1
    You can install gnu getopt from macports - http://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options – Petesh Aug 03 '12 at 07:33