mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-01 04:09:30 +08:00
Fixed logic for cache file generation
This commit is contained in:
parent
480e95147c
commit
71f15f70ea
|
@ -15,8 +15,9 @@ function __fish_complete_ant_targets -d "Print list of targets from build.xml an
|
||||||
end
|
end
|
||||||
function __parse_ant_targets_from_projecthelp -d "Parse ant targets from projecthelp"
|
function __parse_ant_targets_from_projecthelp -d "Parse ant targets from projecthelp"
|
||||||
set -l buildfile $argv[1] # full path to buildfile
|
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
|
for target in $targets
|
||||||
|
# Use [[:graph:]] and [[:print:]] to ignore ANSI escape code
|
||||||
set -l tokens (string match -r '^\s([[:graph:]]+)(?:\s+([[:print:]]+))?' "$target")
|
set -l tokens (string match -r '^\s([[:graph:]]+)(?:\s+([[:print:]]+))?' "$target")
|
||||||
if [ (count $tokens) -ge 3 ]
|
if [ (count $tokens) -ge 3 ]
|
||||||
echo $tokens[2]\t$tokens[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"
|
function __get_ant_targets_from_projecthelp -d "Get ant targets from projecthelp"
|
||||||
set -l buildfile $argv[1] # full path to buildfile
|
set -l buildfile $argv[1] # full path to buildfile
|
||||||
|
|
||||||
set -l cache_dir
|
if [ \( -z "$XDG_CACHE_HOME" \) -o \( ! -d "$XDG_CACHE_HOME" \) ]
|
||||||
if [ \( -n $__fish_user_data_dir \) -a \( -d $__fish_user_data_dir \) ]
|
set XDG_CACHE_HOME "$HOME/.cache/"
|
||||||
set cache_dir $__fish_user_data_dir/ant_completions
|
|
||||||
else
|
|
||||||
set cache_dir "$HOME/.local/share/fish/ant_completions"
|
|
||||||
end
|
end
|
||||||
|
set -l cache_dir "$XDG_CACHE_HOME/fish/ant_completions"
|
||||||
mkdir -p $cache_dir
|
mkdir -p $cache_dir
|
||||||
|
|
||||||
set -l cache_file $cache_dir/(string escape --style=var $buildfile)
|
set -l cache_file $cache_dir/(fish_md5 -s $buildfile)
|
||||||
if [ ! -s $cache_file ]
|
if [ ! -s "$cache_file" ]
|
||||||
# generate cache file if empty
|
# generate cache file if empty
|
||||||
__parse_ant_targets_from_projecthelp $buildfile > $cache_file
|
__parse_ant_targets_from_projecthelp $buildfile > $cache_file
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user