mirror of
https://github.com/denisidoro/navi
synced 2024-11-25 04:50:21 +00:00
Fix regex checks
This commit is contained in:
parent
7c767810e4
commit
0941166c9c
2 changed files with 9 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ARG_REGEX="<[a-zA-Z_]+([- ]?\w+)*>"
|
||||
ARG_REGEX_WITHOUT_BRACKETS="[a-zA-Z_]+([- ]?\w+)*"
|
||||
ARG_REGEX="<${ARG_REGEX_WITHOUT_BRACKETS}>"
|
||||
ARG_DELIMITER="\f"
|
||||
ARG_DELIMITER_2="\v"
|
||||
ARG_DELIMITER_3="\r"
|
||||
|
|
13
src/main.sh
13
src/main.sh
|
@ -39,21 +39,16 @@ handler::main() {
|
|||
fi
|
||||
|
||||
escaped_arg="$(echo "$arg" | tr '-' '_' | tr ' ' '_')"
|
||||
if [[ $escaped_arg =~ $ARG_REGEX ]]; then
|
||||
cmd="$(echo "$cmd" | sed "s|<${arg}>|<${escaped_arg}>|g")"
|
||||
arg="$escaped_arg"
|
||||
else
|
||||
if ! [[ $escaped_arg =~ $ARG_REGEX_WITHOUT_BRACKETS ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cmd="$(echo "$cmd" | sed "s|<${arg}>|<${escaped_arg}>|g")"
|
||||
arg="$escaped_arg"
|
||||
value="$(arg::pick "$arg" "$cheat" || echo "")"
|
||||
if [[ $arg =~ $ARG_REGEX ]]; then
|
||||
|
||||
if [ -z "$value" ]; then
|
||||
echoerr "Unable to fetch suggestions for '$arg'!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue