mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-29 18:51:15 -03:00
__fish_cached: tolerate trailing newline
In POSIX sh, ";" is not a valid statement, leading to errors when the
__fish_cached callback argument has a trailing newline (5c2073135e
(Fix syntax error in __fish_print_port_packages.fish, 2025-11-14)).
Use a newline instead of ";", to avoid this error.
While at it, replace rogue tab characters.
This commit is contained in:
@@ -23,9 +23,15 @@ function __fish_cached --description "Cache the command output for a given amoun
|
||||
set -l cache_file (path normalize $cache_dir/$cache_key)
|
||||
set -l cache_age (path mtime --relative $cache_file)
|
||||
|
||||
set -l populate_cache sh -c "
|
||||
{
|
||||
$argv
|
||||
} >$cache_file || rm $cache_file 2>/dev/null
|
||||
"
|
||||
|
||||
if not test -f $cache_file
|
||||
__fish_cache_put $cache_file
|
||||
sh -c "{ $argv; } >$cache_file || rm $cache_file 2>/dev/null" &
|
||||
$populate_cache &
|
||||
|
||||
if test -n "$last_pid"
|
||||
# wait for at most 1 second if supported
|
||||
@@ -39,7 +45,7 @@ function __fish_cached --description "Cache the command output for a given amoun
|
||||
|
||||
if test $cache_age -gt $max_age
|
||||
__fish_cache_put $cache_file
|
||||
sh -c "{ $argv; } >$cache_file || rm $cache_file 2>/dev/null" &
|
||||
$populate_cache &
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,8 @@ function __fish_print_port_packages
|
||||
type -q -f port || return 1
|
||||
|
||||
__fish_cached -t 250 -k port '
|
||||
printf "all\ncurrent\nactive\ninactive\ninstalled\nuninstalled\noutdated\n"
|
||||
port echo all | awk \'{$1=$1};1\''
|
||||
printf "all\ncurrent\nactive\ninactive\ninstalled\nuninstalled\noutdated\n"
|
||||
port echo all | awk \'{$1=$1};1\'
|
||||
'
|
||||
return 0
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user