fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a53db7256
master
1# localization: skip(private) 2function __fish_cache_sourced_completions 3# Allow a `--name=foo` option which ends up in the filename. 4argparse -s name= --$argv 5or return 6 7set -q argv[ 1 ] 8or return 1 9 10set -l cmd( command -s$argv [ 1 ]) 11or begin 12# If we have no command, we can't get an mtime 13# and so we can't cache 14# The caller can more easily retry 15return 127 16end 17 18set -l cachedir( __fish_make_cache_dir completions) 19or return 20 21set -l stampfile$cachedir /$argv [ 1 ] .stamp 22set -l compfile$cachedir /$argv [ 1 ] .fish 23 24set -l mtime( path mtime --$cmd ) 25 26set -l cmtime0 27path is -rf --$stampfile 28and read cmtime< $stampfile 29 30# If either the timestamp or the completion file don't exist, 31# or the mtime differs, we rerun. 32# 33# That means we'll rerun if the command was up- or downgraded. 34if path is -vrf --$stampfile $compfile || test " $cmtime " -ne " $mtime " 2> /dev/null 35__fish_cache_put $compfile 36$argv > $compfile 37# If the command exited unsuccessfully, we assume it didn't work. 38or return 2 39__fish_cache_put $stampfile 40echo --$mtime > $stampfile 41end 42 43if path is -rf --$compfile 44source $compfile 45return 0 46end 47return 3 48end