mirror of
https://github.com/denisidoro/navi
synced 2024-11-24 20:43:06 +00:00
Prevent printing result in some cases with --no-interpolation (#25)
Fix #19 and #11
This commit is contained in:
parent
9ef95ab2cc
commit
fd9d9974e7
2 changed files with 5 additions and 8 deletions
|
@ -16,7 +16,7 @@ arg::interpolate() {
|
|||
}
|
||||
|
||||
arg::next() {
|
||||
grep -Eo '<[0-9a-zA-Z\-_]+>' \
|
||||
grep -Eo '<[0-9a-zA-Z_]+>' \
|
||||
| head -n1 \
|
||||
| tr -d '<' \
|
||||
| tr -d '>'
|
||||
|
|
11
src/main.sh
11
src/main.sh
|
@ -8,12 +8,7 @@ main() {
|
|||
local cmd="$(selection::command "$selection" "$cheat")"
|
||||
local arg value
|
||||
|
||||
if ! $interpolation; then
|
||||
echo "$cmd"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while true; do
|
||||
while $interpolation; do
|
||||
arg="$(echo "$cmd" | arg::next || echo "")"
|
||||
if [ -z "$arg" ]; then
|
||||
break
|
||||
|
@ -29,7 +24,9 @@ main() {
|
|||
cmd="$(echo "$cmd" | arg::interpolate "$arg" "$value")"
|
||||
done
|
||||
|
||||
if $print; then
|
||||
local readonly unresolved_arg="$(echo "$cmd" | arg::next || echo "")"
|
||||
|
||||
if $print || [ -n "$unresolved_arg" ]; then
|
||||
echo "$cmd"
|
||||
else
|
||||
eval "$cmd"
|
||||
|
|
Loading…
Reference in a new issue