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
  • 73,842
  • 19
  • 118
  • 155
qiushuitian
  • 1,261
  • 4
  • 19
  • 31

1 Answers1

9

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.

Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122
  • 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
  • 2
    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 – Anya Shenanigans Aug 03 '12 at 07:33