From d1944297825acd498ff80f7024bd916fca4ef0c5 Mon Sep 17 00:00:00 2001 From: William Ting Date: Sun, 27 May 2012 10:53:33 -1000 Subject: [PATCH] Test zsh version before using appropriate regex test conditional. As best I can tell, ZSH introduced the "=~" condition somewhere around 4.3.5 or 4.3.9. In either case, autojump will use =~ for versions higher than 4.3.5 and -pcre-match for older versions of ZSH. --- bin/autojump.zsh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/autojump.zsh b/bin/autojump.zsh index f0797ad..96ce02c 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -1,8 +1,15 @@ # determine the data directory according to the XDG Base Directory Specification -if [[ -n ${XDG_DATA_HOME} ]] && [[ ${XDG_DATA_HOME} -pcre-match ${USER} ]]; then - export AUTOJUMP_DATA_DIR="${XDG_DATA_HOME}/autojump" +autoload -U is-at-least + +export AUTOJUMP_DATA_DIR=${HOME}/.local/share/autojump +if is-at-least 4.3.5; then + if [[ -n ${XDG_DATA_HOME} ]] && [[ ${XDG_DATA_HOME} =~ ${USER} ]]; then + export AUTOJUMP_DATA_DIR="${XDG_DATA_HOME}/autojump" + fi else - export AUTOJUMP_DATA_DIR=${HOME}/.local/share/autojump + if [[ -n ${XDG_DATA_HOME} ]] && [[ ${XDG_DATA_HOME} -pcre-match ${USER} ]]; then + export AUTOJUMP_DATA_DIR="${XDG_DATA_HOME}/autojump" + fi fi if [[ ! -e ${AUTOJUMP_DATA_DIR} ]]; then