withGetopt: make long option optional

This commit is contained in:
tv 2017-09-19 20:50:00 +02:00
parent 8179f87e5a
commit 9f85824da2
1 changed files with 8 additions and 4 deletions

View File

@ -45,9 +45,11 @@ in writeDash wrapper-name ''
args=$(${utillinux}/bin/getopt \
-n "$wrapper_name" \
-o "" \
-l ${concatMapStringsSep ","
(opt: opt.long + optionalString (!opt.switch) ":")
(attrValues opts)} \
-l ${shell.escape
(concatMapStringsSep ","
(opt: opt.long + optionalString (!opt.switch) ":")
(filter (opt: opt.long != null)
(attrValues opts)))} \
-s sh \
-- "$@")
if \test $? != 0; then exit 1; fi
@ -65,7 +67,9 @@ in writeDash wrapper-name ''
shift 2
''}
;;
'') opts)}
'') (filterAttrs
(_: opt: opt.long != null)
opts))}
--)
shift
break