Skip to main content
added 76 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k

With zsh, you'd use zparseoptszparseopts:

#! /bin/zsh - zmodload zsh/zutil zparseopts -A ARGUMENTS -p_out: -arg_1: p_out=$ARGUMENTS[--p_out] arg1=$ARGUMENTS[--arg_1] printf 'Argument p_out is "%s"\n' "$p_out" printf 'Argument arg_1 is "%s"\n' "$arg_1" 

But you'd call the script with myscript --p_out foo.

Note that zparseopts doesn't support abbreviating long options or the --p_out=foo syntax like GNU getopt(3) does.

With zsh, you'd use zparseopts:

#! /bin/zsh - zmodload zsh/zutil zparseopts -A ARGUMENTS -p_out: -arg_1: p_out=$ARGUMENTS[--p_out] arg1=$ARGUMENTS[--arg_1] printf 'Argument p_out is "%s"\n' "$p_out" printf 'Argument arg_1 is "%s"\n' "$arg_1" 

But you'd call the script with myscript --p_out foo.

Note that zparseopts doesn't support abbreviating long options or the --p_out=foo syntax like GNU getopt(3) does.

With zsh, you'd use zparseopts:

#! /bin/zsh - zmodload zsh/zutil zparseopts -A ARGUMENTS -p_out: -arg_1: p_out=$ARGUMENTS[--p_out] arg1=$ARGUMENTS[--arg_1] printf 'Argument p_out is "%s"\n' "$p_out" printf 'Argument arg_1 is "%s"\n' "$arg_1" 

But you'd call the script with myscript --p_out foo.

Note that zparseopts doesn't support abbreviating long options or the --p_out=foo syntax like GNU getopt(3) does.

Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k

With zsh, you'd use zparseopts:

#! /bin/zsh - zmodload zsh/zutil zparseopts -A ARGUMENTS -p_out: -arg_1: p_out=$ARGUMENTS[--p_out] arg1=$ARGUMENTS[--arg_1] printf 'Argument p_out is "%s"\n' "$p_out" printf 'Argument arg_1 is "%s"\n' "$arg_1" 

But you'd call the script with myscript --p_out foo.

Note that zparseopts doesn't support abbreviating long options or the --p_out=foo syntax like GNU getopt(3) does.