How can I make bash deal with long param using “getopt” command in mac?

后端 未结 3 798
不思量自难忘°
不思量自难忘° 2021-02-07 01:06

I want to make my bash script deal with long parameters. I found getopt, but it isn\'t supported in OS X. Can anyone tell me why getopt was implemented

3条回答
  •  有刺的猬
    2021-02-07 01:35

    There is a brew bottle for getopt.

    Just run brew install gnu-getopt.

    You can either specify the path for it like /usr/local/Cellar/gnu-getopt/1.1.6/bin/getopt

    Or use brew link --force gnu-getopt so it will be linked in /usr/local/bin/

    Just be aware that forcing linking might be corrupting your system (as it replaces the system getopt by the gnu one).

    See also other answer suggesting to define FLAGS_GETOPT_CMD.

提交回复
热议问题