withGetopt: make long option optional

This commit is contained in:
tv 2017-09-19 20:50:00 +02:00
parent 8179f87e5a
commit 9f85824da2

View File

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