mirror of
https://github.com/denisidoro/navi
synced 2024-11-10 14:04:17 +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
19
src/main.sh
19
src/main.sh
|
@ -39,13 +39,22 @@ handler::main() {
|
|||
fi
|
||||
|
||||
escaped_arg="$(echo "$arg" | tr '-' '_' | tr ' ' '_')"
|
||||
cmd="$(echo "$cmd" | sed "s|<${arg}>|<${escaped_arg}>|g")"
|
||||
arg="$escaped_arg"
|
||||
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 [ -z "$value" ]; then
|
||||
echoerr "Unable to fetch suggestions for '$arg'!"
|
||||
exit 0
|
||||
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'
|
||||
|
|
Loading…
Reference in a new issue