aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-08-13 16:54:43 +0200
committersrdusr <trevorgray@srdusr.com>2023-08-13 16:54:43 +0200
commit857a3431d4bf3a241215c4a5df3be388ea9d2691 (patch)
tree92024530e28655ece1e5b72a540b734280dc742e
parent263433f4181e3d137afccbeb486fc2e27debf824 (diff)
downloaddotfiles-857a3431d4bf3a241215c4a5df3be388ea9d2691.tar.gz
dotfiles-857a3431d4bf3a241215c4a5df3be388ea9d2691.zip
Fixed different executable names for datediff
-rwxr-xr-xneovim.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/neovim.sh b/neovim.sh
index 8c39d71..8591584 100755
--- a/neovim.sh
+++ b/neovim.sh
@@ -11,18 +11,25 @@ NC='\033[0m' # No Color
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
-# Check if necessary applications are installed
+# Define the variable for the date difference command
+DATEDIFF_COMMAND="datediff"
+
+# Check if necessary dependencies are installed
check_dependencies() {
missing_dependencies=()
- for cmd in wget curl xmllint datediff; do
+ for cmd in wget curl xmllint; do
if ! [ -x "$(command -v "$cmd")" ]; then
missing_dependencies+=("$cmd")
fi
done
- if [ "${missing_dependencies[*]}" = "datediff" ] && [ -x "$(command -v dateutils.ddiff)" ]; then
- alias datediff='dateutils.ddiff'
+ if [ -x "$(command -v datediff)" ]; then
+ DATEDIFF_COMMAND="datediff"
+ elif [ -x "$(command -v dateutils.ddiff)" ]; then
+ DATEDIFF_COMMAND="dateutils.ddiff"
+ else
+ missing_dependencies+=("datediff")
fi
if [ ${#missing_dependencies[@]} -gt 0 ]; then
@@ -200,7 +207,7 @@ current_version=$(nvim --version | head -n 1)
new_version=$(xmllint --html --xpath "//pre//code/node()" /tmp/nvim_release_info 2>/dev/null | grep NVIM)
current_datetime_iso=$(date --iso-8601=ns)
new_release_datetime_iso=$(xmllint --html --xpath "string(//relative-time/@datetime)" /tmp/nvim_release_info 2>/dev/null)
-time_since_release=$(datediff "$new_release_datetime_iso" "$current_datetime_iso" -f "%H hours %M minutes ago")
+time_since_release=$("DATEDIFF_COMMAND" "$new_release_datetime_iso" "$current_datetime_iso" -f "%H hours %M minutes ago")
# Check if the new Neovim version is available
if [[ "$new_version" == "" ]]; then