tmux-thumbs/tmux-thumbs.sh
Robert Estelle a0548965f8 sh: Fix meaningless unquoted expansion
[[ ${VALUE} ]] means "expand the VALUE variable, splitting on spaces,
and pass those words as arguments to [[…]]". So if VALUE was the string
'-n blah' then that would expand to '[[ -n blah ]]' which is meaningful
but not at all what was intended.

Instead it appears this intented to check for a non-empty string.
2020-08-04 18:58:50 +02:00

38 lines
808 B
Bash
Executable File

#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PARAMS=()
function add-boolean-param {
VALUE=$(tmux show -vg @thumbs-$1 2> /dev/null)
if [[ "${VALUE}" == "1" ]]; then
PARAMS+=("--$1")
fi
}
function add-option-param {
VALUE=$(tmux show -vg @thumbs-$1 2> /dev/null)
if [ -n "${VALUE}" ]; then
PARAMS+=("--$1=${VALUE}")
fi
}
add-option-param "command"
add-option-param "upcase-command"
add-boolean-param "osc52"
# Remove empty arguments from PARAMS.
# Otherwise, they would choke up tmux-thumbs when passed to it.
for i in "${!PARAMS[@]}"; do
[ -n "${PARAMS[$i]}" ] || unset "PARAMS[$i]"
done
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
${CURRENT_DIR}/target/release/tmux-thumbs --dir "${CURRENT_DIR}" "${PARAMS[@]}"
true