Skip to content

Commit

Permalink
Use pure-bash for version parsing
Browse files Browse the repository at this point in the history
Instead of using "expr" and "cut", use bash regex & substitution
so that we can properly parse the version in an array.
  • Loading branch information
sbakker authored and aruhier committed Nov 27, 2017
1 parent 81f3958 commit 77ec268
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/tools.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/usr/bin/env bash
gnomeVersion="$(expr \
"$(LANGUAGE=en_US.UTF-8 gnome-terminal --version)" : \
'^[^[:digit:]]* \(\([[:digit:]]*\.*\)*\)' \
)"

gnomeVersion=($(
version_string=$(LANGUAGE=en_US.UTF-8 gnome-terminal --version)
[[ $version_string =~ ([0-9]+((\.[0-9]+)*)) ]] && version=${BASH_REMATCH[1]}
echo ${version//./ }
))

# newGnome=1 if the gnome-terminal version >= 3.8
if [[ ("$(echo "$gnomeVersion" | cut -d"." -f1)" = "3" && \
"$(echo "$gnomeVersion" | cut -d"." -f2)" -ge 8) || \
"$(echo "$gnomeVersion" | cut -d"." -f1)" -ge 4 ]]
then newGnome="1"
if [[
( ${gnomeVersion[0]} -eq 3 && ${gnomeVersion[1]} -ge 8 )
|| ${gnomeVersion[0]} -ge 4
]]; then
newGnome="1"
dconfdir=/org/gnome/terminal/legacy/profiles:
else
newGnome=0
Expand Down

0 comments on commit 77ec268

Please sign in to comment.