Prevent printing result in some cases with --no-interpolation (#25)

Fix #19 and #11
This commit is contained in:
Denis Isidoro 2019-09-21 17:29:46 -03:00 committed by GitHub
parent 9ef95ab2cc
commit fd9d9974e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View file

@ -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 '>'

View file

@ -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"