diff --git a/share/functions/__fish_complete_ant_targets.fish b/share/functions/__fish_complete_ant_targets.fish index d3013bb7b..0b50a39da 100644 --- a/share/functions/__fish_complete_ant_targets.fish +++ b/share/functions/__fish_complete_ant_targets.fish @@ -15,8 +15,9 @@ function __fish_complete_ant_targets -d "Print list of targets from build.xml an end function __parse_ant_targets_from_projecthelp -d "Parse ant targets from projecthelp" set -l buildfile $argv[1] # full path to buildfile - set -l targets (ant -p -debug -f $buildfile 2> /dev/null | string match -r '^\s\S+.*$' $projecthelp) + set -l targets (ant -p -debug -f $buildfile 2> /dev/null | string match -r '^\s[[:graph:]].*$') for target in $targets + # Use [[:graph:]] and [[:print:]] to ignore ANSI escape code set -l tokens (string match -r '^\s([[:graph:]]+)(?:\s+([[:print:]]+))?' "$target") if [ (count $tokens) -ge 3 ] echo $tokens[2]\t$tokens[3] @@ -28,16 +29,14 @@ function __fish_complete_ant_targets -d "Print list of targets from build.xml an function __get_ant_targets_from_projecthelp -d "Get ant targets from projecthelp" set -l buildfile $argv[1] # full path to buildfile - set -l cache_dir - if [ \( -n $__fish_user_data_dir \) -a \( -d $__fish_user_data_dir \) ] - set cache_dir $__fish_user_data_dir/ant_completions - else - set cache_dir "$HOME/.local/share/fish/ant_completions" + if [ \( -z "$XDG_CACHE_HOME" \) -o \( ! -d "$XDG_CACHE_HOME" \) ] + set XDG_CACHE_HOME "$HOME/.cache/" end + set -l cache_dir "$XDG_CACHE_HOME/fish/ant_completions" mkdir -p $cache_dir - set -l cache_file $cache_dir/(string escape --style=var $buildfile) - if [ ! -s $cache_file ] + set -l cache_file $cache_dir/(fish_md5 -s $buildfile) + if [ ! -s "$cache_file" ] # generate cache file if empty __parse_ant_targets_from_projecthelp $buildfile > $cache_file end