diff options
author | tv <tv@krebsco.de> | 2017-09-19 20:50:00 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2017-09-19 20:58:23 +0200 |
commit | 9f85824da25311ec096d748798f49d09519e16aa (patch) | |
tree | dfbd427a1c90889821c041ce741641aeb006d7ef | |
parent | 8179f87e5a434ebb21219b657c05a11e6811525f (diff) |
withGetopt: make long option optional
-rw-r--r-- | krebs/5pkgs/simple/withGetopt.nix | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/krebs/5pkgs/simple/withGetopt.nix b/krebs/5pkgs/simple/withGetopt.nix index 21322b783..b7bd40126 100644 --- a/krebs/5pkgs/simple/withGetopt.nix +++ b/krebs/5pkgs/simple/withGetopt.nix @@ -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 |