@@ -671,10 +671,15 @@ function _argproc_filter-call {
671
671
# evaluation much more straightforward.
672
672
local definedFunc=1 filterCall=' _argproc_filter-call:inner'
673
673
if [[ ${filter} =~ ^/(.* )/$ ]]; then
674
- : # TODO
674
+ filter=" $( vals -- " ${BASH_REMATCH[1]} " ) "
675
+ eval " function ${filterCall} {
676
+ local _argproc_regex=${filter}
677
+ [[ \$ 1 =~ \$ {_argproc_regex} ]] && printf '%s\\ n' \"\$ 1\"
678
+ }"
675
679
elif [[ ${filter} =~ ^\{ (.* )\} $ ]]; then
680
+ filter=" ${BASH_REMATCH[1]} "
676
681
eval " function ${filterCall} {
677
- ${BASH_REMATCH[1] }
682
+ ${filter }
678
683
}"
679
684
else
680
685
definedFunc=0
@@ -706,16 +711,8 @@ function _argproc_handler-body {
706
711
local varName=" $4 "
707
712
local result=()
708
713
709
- if [[ ${filter} =~ ^/(.* )/$ ]]; then
710
- # Add a call to perform the regex check on each argument.
711
- filter=" ${BASH_REMATCH[1]} "
712
- local desc=" $( _argproc_arg-description " ${specName} " ) "
713
- result+=(" $( printf \
714
- ' _argproc_regex-filter-check %q %q "$@" || return "$?"\n' \
715
- " ${desc} " " ${filter} "
716
- ) " )
717
- elif [[ ${filter} != ' ' ]]; then
718
- # Add a call to perform the filtering.
714
+ if [[ ${filter} != ' ' ]]; then
715
+ # Add a call to perform the filtering on all the arguments.
719
716
local desc=" $( _argproc_arg-description " ${specName} " ) "
720
717
result+=(" $( printf '
721
718
local _argproc_args
@@ -977,22 +974,6 @@ function _argproc_parse-spec {
977
974
fi
978
975
}
979
976
980
- # Helper (called by code produced by `_argproc_handler-body`) which performs
981
- # a regex filter check.
982
- function _argproc_regex-filter-check {
983
- local desc=" $1 "
984
- local regex=" $2 "
985
- shift 2
986
-
987
- local arg
988
- for arg in " $@ " ; do
989
- if [[ ! (${arg} =~ ${regex} ) ]]; then
990
- error-msg " Invalid value for ${desc} : ${arg} "
991
- return 1
992
- fi
993
- done
994
- }
995
-
996
977
# Sets the description of the named argument based on its type. This function
997
978
# will fail if an argument with the given name was already defined.
998
979
function _argproc_set-arg-description {
0 commit comments