Skip to content

Commit 302a61e

Browse files
committed
tmux_is_at_least: fix IFS issue and improve variable names
1 parent c41154e commit 302a61e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

scripts/helpers.sh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,27 @@ clipboard_copy_command() {
151151
tmux_version="$(tmux -V | cut -d ' ' -f 2)"
152152

153153
tmux_is_at_least() {
154-
if [[ $tmux_version == "$1" || $tmux_version == "master" ]]
155-
then
154+
if [[ $tmux_version == "$1" ]] || [[ $tmux_version == master ]]; then
156155
return 0
157156
fi
158157

159-
local IFS=. i
160-
local -a tver wver
161-
tver=( "$tmux_version" )
162-
wver=( "$1" )
158+
local i
159+
local -a current_version wanted_version
160+
IFS='.' read -ra current_version <<<"$tmux_version"
161+
IFS='.' read -ra wanted_version <<<"$1"
163162

164-
# fill empty fields in tver with zeros
165-
for ((i=${#tver[@]}; i<${#wver[@]}; i++)); do
166-
tver[i]=0
163+
# fill empty fields in current_version with zeros
164+
for ((i = ${#current_version[@]}; i < ${#wanted_version[@]}; i++)); do
165+
current_version[i]=0
167166
done
168167

169-
# fill empty fields in wver with zeros
170-
for ((i=${#wver[@]}; i<${#tver[@]}; i++)); do
171-
wver[i]=0
168+
# fill empty fields in wanted_version with zeros
169+
for ((i = ${#wanted_version[@]}; i < ${#current_version[@]}; i++)); do
170+
wanted_version[i]=0
172171
done
173172

174-
for ((i=0; i<${#tver[@]}; i++)); do
175-
if ((10#${tver[i]} < 10#${wver[i]})); then
173+
for ((i = 0; i < ${#current_version[@]}; i++)); do
174+
if ((10#${current_version[i]} < 10#${wanted_version[i]})); then
176175
return 1
177176
fi
178177
done

0 commit comments

Comments
 (0)