mirror of
https://github.com/denisidoro/navi
synced 2024-11-24 20:43:06 +00:00
[src]: Add condition to check regex for arg/escaped_arg (#109)
Fixes #20
This commit is contained in:
parent
78638c67e4
commit
7c767810e4
1 changed files with 14 additions and 5 deletions
|
@ -39,15 +39,24 @@ 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
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
eval "local $arg"='$value'
|
||||
cmd="$(echo "$cmd" | arg::interpolate "$arg" "$value")"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue