Use set -l to force use of a local variable

Bare set overwrites a global/universal variable if it exists.
This commit is contained in:
Johannes Altmanninger 2020-05-15 07:56:06 +02:00
parent fe6c76d058
commit 49c5f96470
59 changed files with 152 additions and 146 deletions

View file

@ -5,31 +5,31 @@
#
# Usage: ./diff_profiles.fish profile1.log profile2.log > profile_diff.log
set profile1 (cat $argv[1])
set profile2 (cat $argv[2])
set -l profile1 (cat $argv[1])
set -l profile2 (cat $argv[2])
set line_no 0
while set next_line_no (math $line_no + 1) && set -q profile1[$next_line_no] && set -q profile2[$next_line_no]
set -l line_no 0
while set -l next_line_no (math $line_no + 1) && set -q profile1[$next_line_no] && set -q profile2[$next_line_no]
set line_no $next_line_no
set line1 $profile1[$line_no]
set line2 $profile2[$line_no]
set -l line1 $profile1[$line_no]
set -l line2 $profile2[$line_no]
if not string match -qr '^\d+\t\d+' $line1
echo $line1
continue
end
set results1 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line1)
set results2 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line2)
set -l results1 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line1)
set -l results2 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line2)
# times from both files
set time1 $results1[2..3]
set time2 $results2[2..3]
set -l time1 $results1[2..3]
set -l time2 $results2[2..3]
# leftover from both files
set remainder1 $results1[4]
set remainder2 $results2[4]
set -l remainder1 $results1[4]
set -l remainder2 $results2[4]
if not string match -q -- $remainder1 $remainder2
echo Mismatch on line $line_no:

View file

@ -4,7 +4,7 @@
# for object files in this directory.
# This was written for macOS nm.
set FISH_SOURCE_DIR $argv[1]
set -l FISH_SOURCE_DIR $argv[1]
if not test -d "$FISH_SOURCE_DIR"
echo "FISH_SOURCE_DIR not given"
exit 1
@ -20,8 +20,8 @@ set -g whitelist \
# In our nm regex, we are interested in data (dD) and bss (bB) segments.
set -g nm_regex '^([^ ]+) ([dDbB])'
set total_globals 0
set boring_files \
set -l total_globals 0
set -l boring_files \
fish_key_reader.cpp.o \
fish_tests.cpp.o \
fish_indent.cpp.o \
@ -29,7 +29,7 @@ set boring_files \
# return if we should ignore the given symbol name
function should_ignore
set symname $argv[1]
set -l symname $argv[1]
string match -q '*guard variable for*' $symname
and return 0
contains $symname $whitelist
@ -39,16 +39,14 @@ end
# echo a cleaned-up symbol name, e.g. replacing template gunk
function cleanup_syname
set symname $argv[1]
set -l symname $argv[1]
set symname (string replace --all 'std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >' 'wcstring' $symname)
set symname (string replace --all 'std::__1::vector<wcstring, std::__1::allocator<wcstring > >' 'wcstring_list_t' $symname)
echo $symname
end
# Output the declaration for a symbol name in a given file.
function print_decl
set -l objfile $argv[1]
set -l symname $argv[2]
function print_decl -a FISH_SOURCE_DIR objfile symname
set -l varname (string split '::' $symname)[-1]
set -l srcfile (basename $objfile .o)
set -l srcpath $FISH_SOURCE_DIR/src/$srcfile
@ -61,7 +59,7 @@ function print_decl
end
# Guess the variable as the first usage of the name.
# Strip everything after the first =.
set vardecl (egrep -m 1 " $varname\\b" $srcpath | cut -f -1 -d '=' | string trim)
set -l vardecl (egrep -m 1 " $varname\\b" $srcpath | cut -f -1 -d '=' | string trim)
if test -z "$vardecl"
echo "COULD_NOT_FIND_$varname"
return 1
@ -78,7 +76,7 @@ function decl_is_threadsafe
and return 0
# Ordinary types indicating a safe variable.
set safes relaxed_atomic_bool_t std::mutex std::condition_variable std::once_flag sig_atomic_t
set -l safes relaxed_atomic_bool_t std::mutex std::condition_variable std::once_flag sig_atomic_t
for safe in $safes
string match -q "*$safe*" $vardecl
and return 0
@ -93,17 +91,17 @@ function decl_is_threadsafe
end
for file in ./**.o
set filename (basename $file)
set -l filename (basename $file)
# Skip boring files.
contains $filename $boring_files
and continue
for line in (nm -p -P -U $file | egrep $nm_regex)
set matches (string match --regex $nm_regex -- $line)
set -l matches (string match --regex $nm_regex -- $line)
or continue
set symname (cleanup_syname (echo $matches[2] | c++filt))
set -l symname (cleanup_syname (echo $matches[2] | c++filt))
should_ignore $symname
and continue
set vardecl (print_decl $filename $symname)
set -l vardecl (print_decl $FISH_SOURCE_DIR $filename $symname)
decl_is_threadsafe $vardecl
and continue
echo $filename $symname $matches[3] ":" $vardecl

View file

@ -16,11 +16,11 @@ xgettext -k -k_ -kN_ -LC++ --no-wrap -o messages.pot src/*.cpp src/*.h
# This regex handles descriptions for `complete` and `function` statements. These messages are not
# particularly important to translate. Hence the "implicit" label.
set implicit_regex '(?:^| +)(?:complete|function).*? (?:-d|--description) (([\'"]).+?(?<!\\\\)\\2).*'
set -l implicit_regex '(?:^| +)(?:complete|function).*? (?:-d|--description) (([\'"]).+?(?<!\\\\)\\2).*'
# This regex handles explicit requests to translate a message. These are more important to translate
# than messages which should be implicitly translated.
set explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
set -l explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
rm -r /tmp/fish

View file

@ -6,12 +6,12 @@
# We don't include "missingInclude" as that doesn't find our config.h.
# Missing includes will quickly be found by... compiling the thing anyway.
set cppchecks warning,performance,portability,information #,missingInclude
set cppcheck_args
set c_files
set all no
set kernel_name (uname -s)
set machine_type (uname -m)
set -l cppchecks warning,performance,portability,information #,missingInclude
set -l cppcheck_args
set -l c_files
set -l all no
set -l kernel_name (uname -s)
set -l machine_type (uname -m)
argparse a/all p/project= -- $argv
@ -42,7 +42,7 @@ else
# We haven't been asked to lint all the source. If there are uncommitted
# changes lint those, else lint the files in the most recent commit.
# Select (cached files) (modified but not cached, and untracked files)
set files (git diff-index --cached HEAD --name-only)
set -l files (git diff-index --cached HEAD --name-only)
set files $files (git ls-files --exclude-standard --others --modified)
if not set -q files[1]
# No pending changes so lint the files in the most recent commit.

View file

@ -1,6 +1,6 @@
#! /usr/bin/env fish
set TAG $argv[1]
set -l TAG $argv[1]
if test -z "$TAG"
echo "Tag name required."

View file

@ -3,11 +3,11 @@
# This runs C++ files and fish scripts (*.fish) through their respective code
# formatting programs.
#
set git_clang_format no
set c_files
set fish_files
set python_files
set all no
set -l git_clang_format no
set -l c_files
set -l fish_files
set -l python_files
set -l all no
if test "$argv[1]" = --all
set all yes
@ -20,7 +20,7 @@ if set -q argv[1]
end
if test $all = yes
set files (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//')
set -l files (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//')
if set -q files[1]
echo
echo You have uncommitted changes. Cowardly refusing to restyle the entire code base.
@ -34,7 +34,7 @@ else
# We haven't been asked to reformat all the source. If there are uncommitted changes reformat
# those using `git clang-format`. Else reformat the files in the most recent commit.
# Select (cached files) (modified but not cached, and untracked files)
set files (git diff-index --cached HEAD --name-only) (git ls-files --exclude-standard --others --modified)
set -l files (git diff-index --cached HEAD --name-only) (git ls-files --exclude-standard --others --modified)
if set -q files[1]
set git_clang_format yes
else

View file

@ -1,4 +1,5 @@
function __fish_complete_abook_formats --description 'Complete abook formats'
set -l format
abook --formats | while read -l x
switch $x
case "input formats:"

View file

@ -31,11 +31,12 @@ 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
if [ \( -z "$XDG_CACHE_HOME" \) -o \( ! -d "$XDG_CACHE_HOME" \) ]
set XDG_CACHE_HOME "$HOME/.cache"
set -l xdg_cache_home $XDG_CACHE_HOME[1]
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"
set -l cache_dir $xdg_cache_home/fish/ant_completions
mkdir -p $cache_dir
set -l cache_file $cache_dir/(__fish_md5 -s $buildfile)

View file

@ -1,6 +1,6 @@
# Returns exit code of 0 if apm hasn't received a command yet, e.g. `config`
function __fish_apm_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if test (count $cmd) -eq 1
return 0
else if test (count $cmd) -gt 1
@ -20,8 +20,8 @@ end
# Returns exit code of 0 if any command (argv[1..-1]) appears once, ignores flags.
function __fish_apm_using_command
set commands $argv
set cmd (commandline -opc)
set -l commands $argv
set -l cmd (commandline -opc)
if test (count $cmd) -gt 1
set -l command_seen_once 1
for c in $cmd[2..-1]
@ -50,7 +50,7 @@ end
# Check if `commandline` contains a set of subcommands
function __fish_apm_includes_subcommand
set cmd (commandline -opc)
set -l cmd (commandline -opc)
for subcommand in $argv
if contains $subcommand $cmd
return 0

View file

@ -1,7 +1,6 @@
function __fish_complete_apropos
if test (commandline -ct)
set str (commandline -ct)
switch $str
switch (commandline -ct)
case '-**'
case '*'

View file

@ -6,13 +6,13 @@ set -l installed_pkg_subcmds remove
set -l handle_file_pkg_subcmds install
function __fish_apt_subcommand --no-scope-shadowing
set subcommand $argv[1]
set -l subcommand $argv[1]
set -e argv[1]
complete -f -c apt -n "not __fish_seen_subcommand_from $all_subcmds" -a $subcommand $argv
end
function __fish_apt_option
set subcommand $argv[1]
set -l subcommand $argv[1]
set -e argv[1]
complete -f -c apt -n "__fish_seen_subcommand_from $subcommand" $argv
end

View file

@ -1,7 +1,7 @@
# fish completion for arc
function __fish_arc_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if not set -q cmd[2]
return 0
else

View file

@ -1,7 +1,7 @@
# Completion for bundler
function __fish_bundle_no_command -d 'Test if bundle has been given no subcommand'
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end
@ -9,7 +9,7 @@ function __fish_bundle_no_command -d 'Test if bundle has been given no subcomman
end
function __fish_bundle_using_command -d 'Test if bundle has been given a specific subcommand'
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -1,6 +1,6 @@
function __fish_complete_cabal
if type -q -f cabal
set cmd (commandline -poc)
set -l cmd (commandline -poc)
if test (count $cmd) -gt 1
cabal $cmd[2..-1] --list-options
else

View file

@ -1,6 +1,6 @@
function __fish_canto_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -1,5 +1,5 @@
function __fish_composer_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
@ -9,7 +9,7 @@ function __fish_composer_needs_command
end
function __fish_composer_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]

View file

@ -566,7 +566,7 @@ git config -z --get-regexp 'alias\..*' | while read -lz alias command _
# so we skip them here.
string match -q '!*' -- $command; and continue
# Git aliases can contain chars that variable names can't - escape them.
set alias (string replace 'alias.' '' -- $alias | string escape --style=var)
set -l alias (string replace 'alias.' '' -- $alias | string escape --style=var)
set -g __fish_git_alias_$alias $command
end
@ -586,7 +586,7 @@ function __fish_git_using_command
end
function __fish_git_stash_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
__fish_git_using_command stash
or return 2
# The word after the stash command _must_ be the subcommand
@ -600,7 +600,7 @@ function __fish_git_stash_using_command
end
function __fish_git_stash_not_using_subcommand
set cmd (commandline -opc)
set -l cmd (commandline -opc)
__fish_git_using_command stash
or return 2
set cmd $cmd[(contains -i -- "stash" $cmd)..-1]

View file

@ -6,14 +6,15 @@ function __fish_gradle_contains_build_file
end
function __fish_gradle_create_completion_cache_file
set -l xdg_cache_home $XDG_CACHE_HOME
# Set up cache directory
if test -z "$XDG_CACHE_HOME"
set XDG_CACHE_HOME $HOME/.cache
if test -z "$xdg_cache_home"
set xdg_cache_home $HOME/.cache
end
mkdir -m 700 -p "$XDG_CACHE_HOME/gradle-completions"
mkdir -m 700 -p "$xdg_cache_home/gradle-completions"
set -l md5Hash (__fish_md5 -s $argv[1] | string replace -r '.* = ' '')
string trim -- "$XDG_CACHE_HOME/gradle-completions/$md5Hash"
string trim -- "$xdg_cache_home/gradle-completions/$md5Hash"
end
##############################

View file

@ -30,7 +30,7 @@ function __fish_list_heroku_releases
end
function __fish_heroku_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end
@ -38,7 +38,7 @@ function __fish_heroku_needs_command
end
function __fish_heroku_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -7,7 +7,7 @@ function __fish_print_debian_services --description 'Prints services installed'
end
function __fish_invoke_rcd_has_service
set tokens (commandline -opc)
set -l tokens (commandline -opc)
if [ (count $tokens) -eq 2 ]
return 0
else

View file

@ -2,7 +2,7 @@
# Check if command already given
function __fish_prog_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
echo $cmd
if [ (count $cmd) -eq 1 ]
return 0

View file

@ -1,5 +1,5 @@
function __fish_lein_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end

View file

@ -1,5 +1,5 @@
function __fish_lunchy_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if test (count $cmd) -eq 1
return 0
@ -9,8 +9,8 @@ function __fish_lunchy_needs_command
end
function __fish_lunchy_using_command
set cmd (commandline -opc)
set cmd_count (count $cmd)
set -l cmd (commandline -opc)
set -l cmd_count (count $cmd)
if test $cmd_count -lt 2
return 1

View file

@ -13,7 +13,7 @@ function __minikube_no_command
end
function __minikube_using_command
set cmd (commandline -poc)
set -l cmd (commandline -poc)
if test (count $cmd) -gt (count $argv)
set -e cmd[1]
@ -25,8 +25,8 @@ function __minikube_using_command
end
function __minikube_using_option
set cmd (commandline -poc)
set query "("(string join -- "|" (string escape --style=regex $argv))")"
set -l cmd (commandline -poc)
set -l query "("(string join -- "|" (string escape --style=regex $argv))")"
if test (count $cmd) -gt 1
if string match -qr -- $query $cmd[-1]
@ -37,7 +37,7 @@ function __minikube_using_option
end
function __minikube_using_option_value -a option -a value
set cmd (commandline -poc)
set -l cmd (commandline -poc)
if test (count $cmd) -gt 1
string match -qr -- (string escape --style=regex $option)"[= ]"(string escape --style=regex $value) "$cmd"

View file

@ -1,7 +1,7 @@
# Completions for the Elixir build tool mix
function __fish_mix_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end
@ -9,7 +9,7 @@ function __fish_mix_needs_command
end
function __fish_mix_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -8,7 +8,7 @@ source $__fish_data_dir/functions/__fish_npm_helper.fish
set -l npm_install "npm install --global"
function __fish_npm_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
@ -18,7 +18,7 @@ function __fish_npm_needs_command
end
function __fish_npm_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]

View file

@ -1,5 +1,5 @@
function __fish_opam_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0
@ -9,7 +9,7 @@ function __fish_opam_using_command
end
function __fish_opam_at_color
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 2 ]
if [ $cmd[-1] = --color ]
return 0
@ -19,7 +19,7 @@ function __fish_opam_at_color
end
function __fish_opam_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end

View file

@ -25,7 +25,7 @@ if passwd --help >/dev/null 2>&1
complete -c passwd -s w -l warndays -x -d "Define maximum period of password validity"
complete -c passwd -n '__fish_not_contain_opt -s A all' -f -a '(__fish_complete_users)' -d "Account to be altered"
else # Not Linux, so let's see what it is, with the ugly uname
set os_type (uname)
set -l os_type (uname)
switch $os_type
case Darwin # macOS family
complete -c passwd -f -a '(__fish_complete_users)' -d "Account to be altered"

View file

@ -1,7 +1,7 @@
# fish completion for pyenv
function __fish_pyenv_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end
@ -9,7 +9,7 @@ function __fish_pyenv_needs_command
end
function __fish_pyenv_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -1,7 +1,7 @@
# fish completion for rbenv
function __fish_rbenv_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end
@ -10,7 +10,7 @@ function __fish_rbenv_needs_command
end
function __fish_rbenv_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -1,5 +1,5 @@
function __fish_ruby-build_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end

View file

@ -26,8 +26,8 @@ set -l rust_docs (rustc -C help \
| string match -r '^.*[^:]$')
for line in $rust_docs
set docs (string split -m 1 ' ' $line)
set flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \
set -l docs (string split -m 1 ' ' $line)
set -l flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \
$docs[1])
complete -c rustc -x -s C -l codegen -a (string escape -- "$flag") -d "$docs[2]"
end
@ -40,8 +40,8 @@ if rustc +nightly >/dev/null 2>&1
| string match -r '^.*[^:]$')
for line in $rust_docs
set docs (string split -m 1 ' ' $line)
set flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \
set -l docs (string split -m 1 ' ' $line)
set -l flag (string replace -r '^([a-z\-]+\=|[a-z\-]+)(.*)' '$1' \
$docs[1])
complete -c rustc -x -s Z -a (string escape -- "$flag") -d "$docs[2]"
end
@ -57,7 +57,7 @@ set -l rust_docs (rustc -W help \
| string match -r -v '^([a-z\-]+)(\s+)(allow|warn|deny|forbid)')
for line in $rust_docs
set docs (string split -m 1 ' ' $line)
set -l docs (string split -m 1 ' ' $line)
complete -c rustc -x -s W -l warn -a (string escape -- "$docs[1]") -d "$docs[2]"
complete -c rustc -x -s A -l allow -a (string escape -- "$docs[1]") -d "$docs[2]"
complete -c rustc -x -s D -l deny -a (string escape -- "$docs[1]") -d "$docs[2]"

View file

@ -161,7 +161,7 @@ function __rustup_common_suffix
set -l suffix
set -l done 0
while test $done -eq 0 -a $length -le $min_length
set match (string match -r -- ".{$length}\$" "$argv[1]")
set -l match (string match -r -- ".{$length}\$" "$argv[1]")
for arg in $argv[2..-1]
set -l value (string match -r -- ".{$length}\$" "$arg")
if test "$value" = "$match"

View file

@ -1,5 +1,5 @@
function __fish_detect_screen_socket_dir -d "Detect which folder screen uses"
set screen_bin screen
set -l screen_bin screen
if not set -q __fish_screen_socket_dir
set -g __fish_screen_socket_dir ($screen_bin -ls __fish_i_don_t_think_this_will_be_matched | string match -r "(?<=No Sockets found in ).*(?=\.)")
end

View file

@ -13,7 +13,7 @@ set -g __fish_locale_vars LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETAR
#
function __fish_set_is_color -d 'Test if We are specifying a color value for the prompt'
set cmd (commandline -poc)
set -l cmd (commandline -poc)
set -e cmd[1]
for i in $cmd
switch $i
@ -31,7 +31,7 @@ function __fish_set_is_color -d 'Test if We are specifying a color value for the
end
function __fish_set_is_locale -d 'Test if We are specifying a locale value for the prompt'
set cmd (commandline -poc)
set -l cmd (commandline -poc)
set -e cmd[1]
for i in $cmd
switch $i

View file

@ -1,7 +1,7 @@
# Tab completion for sfdx (https://developer.salesforce.com/tools/sfdxcli).
function __fish_sfdx_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -39,13 +39,13 @@ function __fish_snap_use_file -d 'Test if snap command should have files as pote
end
function __fish_snap_subcommand
set subcommand $argv[1]
set -l subcommand $argv[1]
set -e argv[1]
complete -f -c snap -n __fish_snap_no_subcommand -a $subcommand $argv
end
function __fish_snap_option
set subcommand $argv[1]
set -l subcommand $argv[1]
set -e argv[1]
complete -f -c snap -n "__fish_snap_using_subcommand $subcommand" $argv
end
@ -99,7 +99,7 @@ function __fish_snap_using_assertion -d 'Check if certain assertion type is used
end
function __fish_snap_assertion
set assertion $argv[1]
set -l assertion $argv[1]
set -e argv[1]
complete -f -c snap -n '__fish_snap_using_subcommand known; and __fish_snap_no_assertion' -a $assertion
complete -f -c snap -n "__fish_snap_using_assertion $assertion" -a "(__fish_snap_filters $assertion)"\

View file

@ -1,5 +1,5 @@
function __fish_tmuxinator_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -1,5 +1,5 @@
function __fish_travis_needs_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ]
return 0
end
@ -7,7 +7,7 @@ function __fish_travis_needs_command
end
function __fish_travis_using_command
set cmd (commandline -opc)
set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0

View file

@ -1,7 +1,7 @@
function __fish_get_vmctl_vms
for line in (vmctl status | string match -e -v "MAXMEM")
set a (string split " " $line)
set -l a (string split " " $line)
and printf "%s " $a[-1]
end
end

View file

@ -1,5 +1,5 @@
function __fish_complete_wvdial_peers --description 'Complete wvdial peers' --argument cfgfiles
set -q cfgfiles[0]
set -q cfgfiles[1]
or set -l cfgfiles /etc/wvdial.conf ~/.wvdialrc
# test if there is an alternative config file specified

View file

@ -4,7 +4,7 @@
# - for eligible commands, with arguments of different types, only propose second type completions after the first have been selected; for instance, only propose pool members for offline command
# - this has been written mainly from manpages, which are known to be out-of-sync with the real feature set; some discrepancies have been addressed, but it is highly likely that others still lie
set OS ""
set -lx OS ""
switch (uname)
case Linux
set OS Linux

View file

@ -43,7 +43,7 @@ function __fish_zypper_print_repos
# Because spaces and special characters are allowed in repo aliases (bad
# practice though, but allowed), it's impossible to parse the aliases from
# zypper's output correctly. So we fetch them from the repo files.
set repos (cat /etc/zypp/repos.d/*.repo | string replace -rf '^\[(.+)\]$' '$1')
set -l repos (cat /etc/zypp/repos.d/*.repo | string replace -rf '^\[(.+)\]$' '$1')
# Then use the aliases to match their names from zypper's output.
string replace -rf '^[\d\s]+\| ('(string escape -n $repos | string join \|)') +\| (.+)\s+\|.*\|.*\|.*$' '$1\t$2' -- $zypper_lr
end

View file

@ -8,7 +8,7 @@ function __fish_complete_gpg_key_id -d 'Complete using gpg key ids' -a __fish_co
case "uid*"
# Extract user ids (note: gpg escapes colons as '\x3a')
set -l __uid (string split ":" -- $garbage)
set uid (string replace -a '\x3a' ':' -- $__uuid[10])
set -l uid (string replace -a '\x3a' ':' -- $__uuid[10])
printf "%s\t%s\n" $keyid $uid
case "pub*"
# Extract key fingerprints (no subkeys)

View file

@ -1,5 +1,5 @@
function __fish_gnu_complete -d "Wrapper for the complete built-in. Skips the long completions on non-GNU systems"
set is_gnu 0
set -l is_gnu 0
set -l argv_out

View file

@ -1,6 +1,6 @@
function __fish_is_first_token -d 'Test if no non-switch argument has been specified yet'
set cmd (commandline -poc)
set -l cmd (commandline -poc)
set -e cmd[1]
for i in $cmd
switch $i

View file

@ -14,7 +14,7 @@ function __fish_move_last -d "Move the last element of a directory history from
# Append current dir to the end of the destination
set -g (echo $dest) $$dest $PWD
set ssrc $$src
set -l ssrc $$src
# Change dir to the last entry in the source dir-hist
builtin cd $ssrc[$size_src]

View file

@ -53,19 +53,20 @@ function __fish_print_packages
### BEGIN CACHED RESULTS ###
# Set up cache directory
if test -z "$XDG_CACHE_HOME"
set XDG_CACHE_HOME $HOME/.cache
set -l xdg_cache_home $XDG_CACHE_HOME
if test -z "$xdg_cache_home"
set xdg_cache_home $HOME/.cache
end
mkdir -m 700 -p $XDG_CACHE_HOME
mkdir -m 700 -p $xdg_cache_home
# Caches for 5 minutes
if type -q -f pacman
if not set -q only_installed
set cache_file $XDG_CACHE_HOME/.pac-cache.$USER
set -l cache_file $xdg_cache_home/.pac-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
@ -89,7 +90,7 @@ function __fish_print_packages
# If the cache is less than five minutes old, we do not recalculate it
set -l cache_file $XDG_CACHE_HOME/.zypper-cache.$USER
set -l cache_file $xdg_cache_home/.zypper-cache.$USER
if test -f $cache_file
cat $cache_file
set -l age (math (date +%s) - (stat -c '%Y' $cache_file))
@ -109,7 +110,7 @@ function __fish_print_packages
# If the cache is less than six hours old, we do not recalculate it
set cache_file $XDG_CACHE_HOME/.yum-cache.$USER
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))
@ -131,7 +132,7 @@ function __fish_print_packages
# If the cache is less than five minutes old, we do not recalculate it
set cache_file $XDG_CACHE_HOME/.rpm-cache.$USER
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))
@ -154,7 +155,7 @@ function __fish_print_packages
# Determine whether to print installed/available packages
if set -q only_installed
set cache_file $XDG_CACHE_HOME/.eopkg-installed-cache.$USER
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))
@ -168,7 +169,7 @@ function __fish_print_packages
eopkg list-installed -N | cut -d ' ' -f 1 >$cache_file &
return
else
set cache_file $XDG_CACHE_HOME/.eopkg-available-cache.$USER
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))
@ -205,7 +206,7 @@ function __fish_print_packages
# don't save unix time, but the actual date. Also BSD stat is vastly
# different from linux stat and converting its time format is tedious
if type -q -f port
set cache_file $XDG_CACHE_HOME/.port-cache.$USER
set -l cache_file $xdg_cache_home/.port-cache.$USER
if test -e $cache_file
# Delete if cache is older than 15 minutes
find "$cache_file" -ctime +15m | awk '{$1=$1;print}' | xargs rm

View file

@ -15,8 +15,8 @@ function down-or-search -d "Depending on cursor position and current mode, eithe
# We are not already in search mode.
# If we are on the bottom line, start search mode,
# otherwise move down
set lineno (commandline -L)
set line_count (count (commandline))
set -l lineno (commandline -L)
set -l line_count (count (commandline))
switch $lineno
case $line_count

View file

@ -26,7 +26,7 @@ function funced --description 'Edit function definition'
return 1
end
set funcname $argv[1]
set -l funcname $argv[1]
# Check VISUAL first since theoretically EDITOR could be ed.
set -l editor

View file

@ -13,7 +13,7 @@ function prompt_pwd --description "Print the current working directory, shortene
or set -l fish_prompt_pwd_dir_length 1
# Replace $HOME with "~"
set realhome ~
set -l realhome ~
set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD)
if [ $fish_prompt_pwd_dir_length -eq 0 ]

View file

@ -1,7 +1,7 @@
# This defines a compatibility shim for the `trap` command found in other shells like bash and zsh.
function __trap_translate_signal
set upper (echo $argv[1]|tr a-z A-Z)
set -l upper (echo $argv[1]|tr a-z A-Z)
string replace -r '^SIG' '' -- $upper
end

View file

@ -2,10 +2,12 @@
# author: Acidhub - https://acidhub.click/
function fish_prompt -d "Write out the prompt"
set laststatus $status
set -l laststatus $status
set -l git_info
if set -l git_branch (command git symbolic-ref HEAD 2>/dev/null | string replace refs/heads/ '')
set git_branch (set_color -o blue)"$git_branch"
set -l git_status
if command git diff-index --quiet HEAD --
if set -l count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null)
echo $count | read -l ahead behind

View file

@ -3,12 +3,13 @@
function fish_prompt --description 'Write out the prompt, prepending the Debian chroot environment if present'
# Set variable identifying the chroot you work in (used in the prompt below)
if not set -q debian_chroot
set -l debian_chroot $debian_chroot
if not set -q debian_chroot[1]
and test -r /etc/debian_chroot
set debian_chroot (cat /etc/debian_chroot)
end
if not set -q __fish_debian_chroot_prompt
and set -q debian_chroot
and set -q debian_chroot[1]
and test -n "$debian_chroot"
set -g __fish_debian_chroot_prompt "($debian_chroot)"
end

View file

@ -32,8 +32,8 @@ function fish_prompt
function _nim_prompt_wrapper
set retc $argv[1]
set field_name $argv[2]
set field_value $argv[3]
set -l field_name $argv[2]
set -l field_value $argv[3]
set_color normal
set_color $retc
@ -107,7 +107,7 @@ function fish_prompt
and _nim_prompt_wrapper $retc V (basename "$VIRTUAL_ENV")
# git
set prompt_git (fish_git_prompt | string trim -c ' ()')
set -l prompt_git (fish_git_prompt | string trim -c ' ()')
test -n "$prompt_git"
and _nim_prompt_wrapper $retc G $prompt_git

View file

@ -76,6 +76,7 @@ function fish_prompt
set -l cwd $cyan(basename (prompt_pwd))
set -l repo_info
if set -l repo_type (_repo_type)
set -l repo_branch $red(_repo_branch_name $repo_type)
set repo_info "$blue $repo_type:($repo_branch$blue)"

View file

@ -8,9 +8,9 @@
#
for i in $argv
set template_out (basename $i .in).out
set template_err (basename $i .in).err
set template_status (basename $i .in).status
set -l template_out (basename $i .in).out
set -l template_err (basename $i .in).err
set -l template_status (basename $i .in).status
fish <$i >$template_out 2>$template_err
echo $status >$template_status

View file

@ -12,6 +12,7 @@ set -x FISH_UNIT_TESTS_RUNNING 1
cd (dirname (status -f))
# Test files specified on commandline, or all checks.
set -l files_to_test
if set -q argv[1]
set files_to_test checks/$argv.fish
else

View file

@ -138,10 +138,10 @@ end
for program in {g,}date
if command -q $program && $program --version 1>/dev/null 2>/dev/null
set -g milli $program
set unit ms
set -g unit ms
break
else
set unit sec
set -g unit sec
end
end