mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 01:46:40 +00:00
Bugfix: add fix to tmux next-* versions.
This commit is contained in:
@@ -7,61 +7,64 @@ source "$TMUXIFIER/lib/util.sh"
|
|||||||
|
|
||||||
# Provide tmuxifier help
|
# Provide tmuxifier help
|
||||||
if calling-help "$@"; then
|
if calling-help "$@"; then
|
||||||
echo "usage: tmuxifier tmux-version [<target-version>]
|
echo "usage: tmuxifier tmux-version [<target-version>]
|
||||||
|
|
||||||
Outputs current Tmux version. If given optional target-version it outputs one
|
Outputs current Tmux version. If given optional target-version it outputs one
|
||||||
of three possible characters indicating if the current Tmux version number is
|
of three possible characters indicating if the current Tmux version number is
|
||||||
equal to, less than, or greater than the <target-version>.
|
equal to, less than, or greater than the <target-version>.
|
||||||
|
|
||||||
The three possible outputs are \"=\", \"<\", and \">\"."
|
The three possible outputs are \"=\", \"<\", and \">\"."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The vercomp() function is shamelessly ripped/borrowed from the following
|
# The vercomp() function is shamelessly ripped/borrowed from the following
|
||||||
# StackOverflow answer: http://stackoverflow.com/a/4025065/42146
|
# StackOverflow answer: http://stackoverflow.com/a/4025065/42146
|
||||||
vercomp () {
|
vercomp() {
|
||||||
if [[ $1 == $2 ]]; then return 0; fi
|
if [[ $1 == $2 ]]; then return 0; fi
|
||||||
|
|
||||||
local IFS=.
|
local IFS=.
|
||||||
local i ver1=($1) ver2=($2)
|
local i ver1=($1) ver2=($2)
|
||||||
|
|
||||||
# fill empty fields in ver1 with zeros
|
# fill empty fields in ver1 with zeros
|
||||||
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do ver1[i]=0; done
|
for ((i = ${#ver1[@]}; i < ${#ver2[@]}; i++)); do ver1[i]=0; done
|
||||||
|
|
||||||
for ((i=0; i<${#ver1[@]}; i++)); do
|
for ((i = 0; i < ${#ver1[@]}; i++)); do
|
||||||
# fill empty fields in ver2 with zeros
|
# fill empty fields in ver2 with zeros
|
||||||
if [[ -z ${ver2[i]} ]]; then ver2[i]=0; fi
|
if [[ -z ${ver2[i]} ]]; then ver2[i]=0; fi
|
||||||
|
|
||||||
if ((10#${ver1[i]} > 10#${ver2[i]})); then
|
if ((10#${ver1[i]} > 10#${ver2[i]})); then
|
||||||
return 1
|
return 1
|
||||||
elif ((10#${ver1[i]} < 10#${ver2[i]})); then
|
elif ((10#${ver1[i]} < 10#${ver2[i]})); then
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
version=$(tmux -V)
|
version=$(tmux -V)
|
||||||
version=${version/tmux /}
|
version=${version/tmux /}
|
||||||
|
|
||||||
|
# Fix for tmux next-* versions
|
||||||
|
version=${version/next-/}
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "$version"
|
echo "$version"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$version" == "master" ]; then
|
if [ "$version" == "master" ]; then
|
||||||
# When version string is "master", tmux was compiled from source, and we
|
# When version string is "master", tmux was compiled from source, and we
|
||||||
# assume it's later than whatever the <target-version> is.
|
# assume it's later than whatever the <target-version> is.
|
||||||
echo '>'
|
echo '>'
|
||||||
else
|
else
|
||||||
# Fix for "1.9a" version comparison, as vercomp() can only deal with
|
# Fix for "1.9a" version comparison, as vercomp() can only deal with
|
||||||
# purely numeric version numbers.
|
# purely numeric version numbers.
|
||||||
version=${version//+([a-zA-Z])/}
|
version=${version//+([a-zA-Z])/}
|
||||||
|
|
||||||
vercomp "$version" "$1"
|
vercomp "$version" "$1"
|
||||||
case $? in
|
case $? in
|
||||||
0) echo '=';;
|
0) echo '=' ;;
|
||||||
1) echo '>';;
|
1) echo '>' ;;
|
||||||
2) echo '<';;
|
2) echo '<' ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user