mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 14:43:55 +08:00
Some more precautionary uses of set --local
This commit is contained in:
parent
62f1ed0b5e
commit
ec2371fb79
|
@ -12,8 +12,8 @@ if not contains -- $TAG (git tag)
|
|||
exit 1
|
||||
end
|
||||
|
||||
set committers_to_tag (mktemp)
|
||||
set committers_from_tag (mktemp)
|
||||
set -l committers_to_tag (mktemp)
|
||||
set -l committers_from_tag (mktemp)
|
||||
|
||||
# You might think it would be better to case-insensitively sort/compare the names
|
||||
# to produce a more natural-looking list.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function __fish_append -d "Internal completion function for appending string to the commandline" --argument sep
|
||||
set -e argv[1]
|
||||
set str (commandline -tc | string replace -rf "(.*$sep)[^$sep]*" '$1' | string replace -r -- '--.*=' '')
|
||||
set -l str (commandline -tc | string replace -rf "(.*$sep)[^$sep]*" '$1' | string replace -r -- '--.*=' '')
|
||||
printf "%s\n" "$str"$argv
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
function __fish_print_user_ids
|
||||
if command -sq getent
|
||||
for line in (getent passwd)
|
||||
set v (string split : -- $line)
|
||||
set -l v (string split : -- $line)
|
||||
printf "%s\t%s\n" $v[3] $v[1]
|
||||
end
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ end
|
|||
function __fish_print_group_ids
|
||||
if command -sq getent
|
||||
for line in (getent group)
|
||||
set v (string split : -- $line)
|
||||
set -l v (string split : -- $line)
|
||||
printf "%s\t%s\n" $v[3] $v[1]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowin
|
|||
set -l options_with_param $argv
|
||||
|
||||
if not string length -q -- $subcommand
|
||||
set cmd (commandline -cop) (commandline -ct)
|
||||
set -l cmd (commandline -cop) (commandline -ct)
|
||||
while set -q cmd[1]
|
||||
set -l token $cmd[1]
|
||||
set -e cmd[1]
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
# of the directory under the cursor.
|
||||
|
||||
function __fish_list_current_token -d "List contents of token under the cursor if it is a directory, otherwise list the contents of the current directory"
|
||||
set val (eval echo (commandline -t))
|
||||
set -l val (eval echo (commandline -t))
|
||||
printf "\n"
|
||||
if test -d $val
|
||||
ls $val
|
||||
else
|
||||
set dir (dirname -- $val)
|
||||
set -l dir (dirname -- $val)
|
||||
if test $dir != . -a -d $dir
|
||||
ls $dir
|
||||
else
|
||||
|
|
|
@ -38,7 +38,7 @@ function __yarn_filtered_list_packages
|
|||
end
|
||||
|
||||
function __yarn_find_package_json
|
||||
set parents (__fish_parent_directories (pwd -P))
|
||||
set -l parents (__fish_parent_directories (pwd -P))
|
||||
|
||||
for p in $parents
|
||||
if test -f "$p/package.json"
|
||||
|
|
|
@ -113,8 +113,8 @@ function __fish_print_packages
|
|||
set -l cache_file $xdg_cache_home/.yum-cache.$USER
|
||||
if test -f $cache_file
|
||||
cat $cache_file
|
||||
set age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set max_age 21600
|
||||
set -l age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set -l max_age 21600
|
||||
if test $age -lt $max_age
|
||||
return
|
||||
end
|
||||
|
@ -135,8 +135,8 @@ function __fish_print_packages
|
|||
set -l cache_file $xdg_cache_home/.rpm-cache.$USER
|
||||
if test -f $cache_file
|
||||
cat $cache_file
|
||||
set age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set max_age 250
|
||||
set -l age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set -l max_age 250
|
||||
if test $age -lt $max_age
|
||||
return
|
||||
end
|
||||
|
@ -158,8 +158,8 @@ function __fish_print_packages
|
|||
set -l cache_file $xdg_cache_home/.eopkg-installed-cache.$USER
|
||||
if test -f $cache_file
|
||||
cat $cache_file
|
||||
set age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set max_age 500
|
||||
set -l age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set -l max_age 500
|
||||
if test $age -lt $max_age
|
||||
return
|
||||
end
|
||||
|
@ -172,8 +172,8 @@ function __fish_print_packages
|
|||
set -l cache_file $xdg_cache_home/.eopkg-available-cache.$USER
|
||||
if test -f $cache_file
|
||||
cat $cache_file
|
||||
set age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set max_age 500
|
||||
set -l age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set -l max_age 500
|
||||
if test $age -lt $max_age
|
||||
return
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
function __fish_seen_argument
|
||||
argparse 's/short=+' 'o/old=+' 'l/long=+' -- $argv
|
||||
|
||||
set cmd (commandline -co)
|
||||
set -l cmd (commandline -co)
|
||||
set -e cmd[1]
|
||||
for t in $cmd
|
||||
for s in $_flag_s
|
||||
|
|
|
@ -35,7 +35,7 @@ function realpath -d "return an absolute path without symlinks"
|
|||
|
||||
# We don't implement any of the other flags so if any are set it's an error.
|
||||
if string match -q '_flag_*' -- (set -l)
|
||||
set flags (set -l | string replace --filter _flag_ '')
|
||||
set -l flags (set -l | string replace --filter _flag_ '')
|
||||
printf (_ "%s: These flags are not allowed by fish realpath: '%s'") realpath "$flags" >&2
|
||||
echo >&2
|
||||
__fish_print_help realpath
|
||||
|
|
|
@ -65,7 +65,7 @@ function trap -d 'Perform an action when the shell receives a signal'
|
|||
|
||||
for i in $argv
|
||||
set -l sig (__trap_translate_signal $i)
|
||||
set sw (__trap_switch $sig)
|
||||
set -l sw (__trap_switch $sig)
|
||||
|
||||
if test -n "$sig"
|
||||
echo "function __trap_handler_$sig $sw; $cmd; end" | source
|
||||
|
|
|
@ -14,7 +14,7 @@ function up-or-search -d "Depending on cursor position and current mode, either
|
|||
# We are not already in search mode.
|
||||
# If we are on the top line, start search mode,
|
||||
# otherwise move up
|
||||
set lineno (commandline -L)
|
||||
set -l lineno (commandline -L)
|
||||
|
||||
switch $lineno
|
||||
case 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user