From 8b79f4e5c93acf7e643ef5b7b854fa7ad5a39487 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Fri, 4 Aug 2017 18:02:24 -0700 Subject: [PATCH] use the new `set -a` and `set -p` in our scripts --- share/functions/__fish_bind_test1.fish | 3 +-- share/functions/__fish_bind_test2.fish | 3 +-- share/functions/__fish_complete_mount_opts.fish | 8 ++++---- share/functions/__fish_complete_proc.fish | 16 ++++++++-------- .../__fish_complete_subcommand_root.fish | 4 +--- share/functions/__fish_contains_opt.fish | 4 ++-- share/functions/__fish_git_prompt.fish | 8 ++++---- share/functions/__fish_hg_prompt.fish | 12 ++++++------ .../__fish_make_completion_signals.fish | 7 ++++--- share/functions/__fish_print_filesystems.fish | 5 ++--- share/functions/__fish_print_hostnames.fish | 4 ++-- share/functions/__fish_set_locale.fish | 6 +++--- share/functions/__terlar_git_prompt.fish | 14 +++++++------- share/functions/abbr.fish | 4 ++-- share/functions/cd.fish | 2 +- share/functions/cdh.fish | 2 +- share/functions/help.fish | 6 +++--- share/functions/history.fish | 8 ++++---- share/functions/ls.fish | 2 +- share/functions/pushd.fish | 2 +- share/functions/realpath.fish | 4 ++-- share/functions/string.fish | 2 +- share/functions/umask.fish | 4 ++-- 23 files changed, 63 insertions(+), 67 deletions(-) diff --git a/share/functions/__fish_bind_test1.fish b/share/functions/__fish_bind_test1.fish index fa5fe4de1..a636ecd89 100644 --- a/share/functions/__fish_bind_test1.fish +++ b/share/functions/__fish_bind_test1.fish @@ -1,4 +1,3 @@ - function __fish_bind_test1 set -l args set -l use_keys no @@ -10,7 +9,7 @@ function __fish_bind_test1 case "-*" case "*" - set args $args $i + set -a args $i end end diff --git a/share/functions/__fish_bind_test2.fish b/share/functions/__fish_bind_test2.fish index fded8b262..74f594fcb 100644 --- a/share/functions/__fish_bind_test2.fish +++ b/share/functions/__fish_bind_test2.fish @@ -1,4 +1,3 @@ - function __fish_bind_test2 set -l args for i in (commandline -poc) @@ -6,7 +5,7 @@ function __fish_bind_test2 case "-*" case "*" - set args $args $i + set -a args $i end end diff --git a/share/functions/__fish_complete_mount_opts.fish b/share/functions/__fish_complete_mount_opts.fish index 2a98c18a2..9afc4020b 100644 --- a/share/functions/__fish_complete_mount_opts.fish +++ b/share/functions/__fish_complete_mount_opts.fish @@ -145,13 +145,13 @@ function __fish_complete_mount_opts switch (string replace -r '=.*' '=' -- $last_arg) case uid= - set fish_mount_opts $fish_mount_opts uid=(__fish_print_user_ids) + set -a fish_mount_opts uid=(__fish_print_user_ids) case gid= - set fish_mount_opts $fish_mount_opts gid=(__fish_print_group_ids) + set -a fish_mount_opts gid=(__fish_print_group_ids) case setuid= - set fish_mount_opts $fish_mount_opts setuid=(__fish_print_user_ids) + set -a fish_mount_opts setuid=(__fish_print_user_ids) case setgid= - set fish_mount_opts $fish_mount_opts setgid=(__fish_print_group_ids) + set -a fish_mount_opts setgid=(__fish_print_group_ids) end diff --git a/share/functions/__fish_complete_proc.fish b/share/functions/__fish_complete_proc.fish index ab92bdfb3..8fb5d7260 100644 --- a/share/functions/__fish_complete_proc.fish +++ b/share/functions/__fish_complete_proc.fish @@ -14,33 +14,33 @@ function __fish_complete_proc --description 'Complete by list of running process set ps_opt -A -o command # Erase everything after the first space - set sed_cmds $sed_cmds 's/ .*//' + set -a sed_cmds 's/ .*//' # Erases weird stuff Linux gives like kworker/0:0 - set sed_cmds $sed_cmds 's|/[0-9]:[0-9]]$||g' + set -a sed_cmds 's|/[0-9]:[0-9]]$||g' # Retain the last path component only - set sed_cmds $sed_cmds 's|.*/||g' + set -a sed_cmds 's|.*/||g' # Strip off square brackets. Cute, huh? - set sed_cmds $sed_cmds 's/[][]//g' + set -a sed_cmds 's/[][]//g' # Erase things that are just numbers - set sed_cmds $sed_cmds 's/^[0-9]*$//' + set -a sed_cmds 's/^[0-9]*$//' else # OS X, BSD. Preserve leading spaces. set ps_opt axc -o comm # Delete parenthesized (zombie) processes - set sed_cmds $sed_cmds '/(.*)/d' + set -a sed_cmds '/(.*)/d' end # Append sed command to delete first line (the header) - set sed_cmds $sed_cmds '1d' + set -a sed_cmds '1d' # Append sed commands to delete leading dashes and trailing spaces # In principle, commands may have trailing spaces, but ps emits space padding on OS X - set sed_cmds $sed_cmds 's/^-//' 's/ *$//' + set -a sed_cmds 's/^-//' 's/ *$//' # Run ps, pipe it through our massive set of sed commands, then sort and unique ps $ps_opt | sed '-e '$sed_cmds | sort -u diff --git a/share/functions/__fish_complete_subcommand_root.fish b/share/functions/__fish_complete_subcommand_root.fish index f27984543..736abeeff 100644 --- a/share/functions/__fish_complete_subcommand_root.fish +++ b/share/functions/__fish_complete_subcommand_root.fish @@ -1,6 +1,4 @@ - - function __fish_complete_subcommand_root -d "Run the __fish_complete_subcommand function using a PATH containing /sbin and /usr/sbin" - set -lx PATH /sbin /usr/sbin $PATH ^/dev/null + set -lx -p PATH /sbin /usr/sbin ^/dev/null __fish_complete_subcommand $argv end diff --git a/share/functions/__fish_contains_opt.fish b/share/functions/__fish_contains_opt.fish index ffd139ad6..0d10d6d23 100644 --- a/share/functions/__fish_contains_opt.fish +++ b/share/functions/__fish_contains_opt.fish @@ -6,7 +6,7 @@ function __fish_contains_opt -d "Checks if a specific option has been given in t for i in $argv if test -n "$next_short" set next_short - set short_opt $short_opt $i + set -a short_opt $i else switch $i case -s @@ -15,7 +15,7 @@ function __fish_contains_opt -d "Checks if a specific option has been given in t echo __fish_contains_opt: Unknown option $i >&2 return 1 case '*' - set long_opt $long_opt $i + set -a long_opt $i end end end diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index d5e690cf1..9d3b4fb9d 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -724,7 +724,7 @@ end set -l varargs for var in repaint describe_style show_informative_status showdirtystate showstashstate showuntrackedfiles showupstream - set varargs $varargs --on-variable __fish_git_prompt_$var + set -a varargs --on-variable __fish_git_prompt_$var end function __fish_git_prompt_repaint $varargs --description "Event handler, repaints prompt when functionality changes" if status --is-interactive @@ -741,9 +741,9 @@ end set -l varargs for var in '' _prefix _suffix _bare _merging _cleanstate _invalidstate _upstream _flags _branch _dirtystate _stagedstate _branch_detached _stashstate _untrackedfiles - set varargs $varargs --on-variable __fish_git_prompt_color$var + set -a varargs --on-variable __fish_git_prompt_color$var end -set varargs $varargs --on-variable __fish_git_prompt_showcolorhints +set -a varargs --on-variable __fish_git_prompt_showcolorhints function __fish_git_prompt_repaint_color $varargs --description "Event handler, repaints prompt when any color changes" if status --is-interactive set -l var $argv[3] @@ -762,7 +762,7 @@ end set -l varargs for var in cleanstate dirtystate invalidstate stagedstate stashstate stateseparator untrackedfiles upstream_ahead upstream_behind upstream_diverged upstream_equal upstream_prefix - set varargs $varargs --on-variable __fish_git_prompt_char_$var + set -a varargs --on-variable __fish_git_prompt_char_$var end function __fish_git_prompt_repaint_char $varargs --description "Event handler, repaints prompt when any char changes" if status --is-interactive diff --git a/share/functions/__fish_hg_prompt.fish b/share/functions/__fish_hg_prompt.fish index ee02d2b9b..0ab444514 100644 --- a/share/functions/__fish_hg_prompt.fish +++ b/share/functions/__fish_hg_prompt.fish @@ -70,17 +70,17 @@ function __fish_hg_prompt --description 'Write out the hg prompt' # Add a character for each file status if we have one switch $line case 'A ' - set hg_statuses $hg_statuses added + set -a hg_statuses added case 'M ' ' M' - set hg_statuses $hg_statuses modified + set -a hg_statuses modified case 'C ' - set hg_statuses $hg_statuses copied + set -a hg_statuses copied case 'D ' ' D' - set hg_statuses $hg_statuses deleted + set -a hg_statuses deleted case '\? ' - set hg_statuses $hg_statuses untracked + set -a hg_statuses untracked case 'U*' '*U' 'DD' 'AA' - set hg_statuses $hg_statuses unmerged + set -a hg_statuses unmerged end end diff --git a/share/functions/__fish_make_completion_signals.fish b/share/functions/__fish_make_completion_signals.fish index 2dd88ac47..cac6e135f 100644 --- a/share/functions/__fish_make_completion_signals.fish +++ b/share/functions/__fish_make_completion_signals.fish @@ -2,6 +2,8 @@ function __fish_make_completion_signals --description 'Make list of kill signals set -q __kill_signals and return 0 + set -g __kill_signals + # Some systems use the GNU coreutils kill command where `kill -L` produces an extended table # format that looks like this: # @@ -16,18 +18,17 @@ function __fish_make_completion_signals --description 'Make list of kill signals # Posix systems print out the name of a signal using 'kill -l SIGNUM'. complete -c kill -s l --description "List names of available signals" for i in (seq 31) - set -g __kill_signals $__kill_signals $i" "(kill -l $i | tr '[:lower:]' '[:upper:]') + set -a __kill_signals $i" "(kill -l $i | tr '[:lower:]' '[:upper:]') end else # Debian and some related systems use 'kill -L' to write out a numbered list # of signals. Use this to complete on both number _and_ on signal name. complete -c kill -s L --description "List codes and names of available signals" - set -g __kill_signals kill -L | sed -e 's/^ //; s/ */ /g; y/ /\n/' | while read -l signo test -z "$signo" and break # the sed above produces one blank line at the end read -l signame - set -g __kill_signals $__kill_signals "$signo $signame" + set -a __kill_signals "$signo $signame" end end end diff --git a/share/functions/__fish_print_filesystems.fish b/share/functions/__fish_print_filesystems.fish index b14be36bc..d329ecd0c 100644 --- a/share/functions/__fish_print_filesystems.fish +++ b/share/functions/__fish_print_filesystems.fish @@ -1,8 +1,7 @@ - function __fish_print_filesystems -d "Print a list of all known filesystem types" set -l fs adfs affs autofs coda coherent cramfs devpts efs ext ext2 ext3 - set fs $fs hfs hpfs iso9660 jfs minix msdos ncpfs nfs ntfs proc qnx4 ramfs - set fs $fs reiserfs romfs smbfs sysv tmpfs udf ufs umsdos vfat xenix xfs xiafs + set -a fs hfs hpfs iso9660 jfs minix msdos ncpfs nfs ntfs proc qnx4 ramfs + set -a fs reiserfs romfs smbfs sysv tmpfs udf ufs umsdos vfat xenix xfs xiafs # Mount has helper binaries to mount filesystems # These are called mount.* and are placed somewhere in $PATH set -l mountfs $PATH/mount.* $PATH/mount_* diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish index efa3cac4f..ebe160a74 100644 --- a/share/functions/__fish_print_hostnames.fish +++ b/share/functions/__fish_print_hostnames.fish @@ -53,7 +53,7 @@ function __fish_print_hostnames -d "Print a list of known hostnames" set -l orig_dir $PWD set -l paths for config in $argv - set paths $paths (cat $config ^/dev/null \ + set -a paths (cat $config ^/dev/null \ # Keep only Include lines | string match -r -i '^\s*Include\s+.+' \ # Remove Include syntax @@ -91,7 +91,7 @@ function __fish_print_hostnames -d "Print a list of known hostnames" # Print hosts from system wide ssh configuration file string match -r -i '^\s*Host\s+\S+' <$file | string replace -r -i '^\s*Host\s+' '' | string trim | string replace -r '\s+' ' ' | string split ' ' | string match -v '*\**' # Extract known_host paths. - set known_hosts $known_hosts (string match -ri '^\s*UserKnownHostsFile|^\s*GlobalKnownHostsFile' <$file | string replace -ri '.*KnownHostsFile\s*' '') + set -a known_hosts (string match -ri '^\s*UserKnownHostsFile|^\s*GlobalKnownHostsFile' <$file | string replace -ri '.*KnownHostsFile\s*' '') end end for file in $known_hosts diff --git a/share/functions/__fish_set_locale.fish b/share/functions/__fish_set_locale.fish index 125b79d08..cb0e28674 100644 --- a/share/functions/__fish_set_locale.fish +++ b/share/functions/__fish_set_locale.fish @@ -10,9 +10,9 @@ function __fish_set_locale set -l LOCALE_VARS - set LOCALE_VARS $LOCALE_VARS LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE - set LOCALE_VARS $LOCALE_VARS LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS - set LOCALE_VARS $LOCALE_VARS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION + set -a LOCALE_VARS LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE + set -a LOCALE_VARS LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS + set -a LOCALE_VARS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION # We check LC_ALL to figure out if we have a locale but we don't set it later. That is because # locale.conf doesn't allow it so we should not set it. diff --git a/share/functions/__terlar_git_prompt.fish b/share/functions/__terlar_git_prompt.fish index 46013d928..f1fcedf33 100644 --- a/share/functions/__terlar_git_prompt.fish +++ b/share/functions/__terlar_git_prompt.fish @@ -52,19 +52,19 @@ function __terlar_git_prompt --description 'Write out the git prompt' switch $i case 'A ' - set gs $gs added + set -a gs added case 'M ' ' M' - set gs $gs modified + set -a gs modified case 'R ' - set gs $gs renamed + set -a gs renamed case 'C ' - set gs $gs copied + set -a gs copied case 'D ' ' D' - set gs $gs deleted + set -a gs deleted case '\?\?' - set gs $gs untracked + set -a gs untracked case 'U*' '*U' 'DD' 'AA' - set gs $gs unmerged + set -a gs unmerged end end diff --git a/share/functions/abbr.fish b/share/functions/abbr.fish index 508965fd6..33e249502 100644 --- a/share/functions/abbr.fish +++ b/share/functions/abbr.fish @@ -1,7 +1,7 @@ function abbr --description "Manage abbreviations using new fish 3.0 scheme." set -l options --stop-nonopt --exclusive 'a,r,e,l,s' --exclusive 'g,U' - set options $options 'h/help' 'a/add' 'r/rename' 'e/erase' 'l/list' 's/show' - set options $options 'g/global' 'U/universal' + set -a options 'h/help' 'a/add' 'r/rename' 'e/erase' 'l/list' 's/show' + set -a options 'g/global' 'U/universal' argparse -n abbr $options -- $argv or return diff --git a/share/functions/cd.fish b/share/functions/cd.fish index 9f426c031..23f169d2c 100644 --- a/share/functions/cd.fish +++ b/share/functions/cd.fish @@ -35,7 +35,7 @@ function cd --description "Change directory" or set -l dirprev set -q dirprev[$MAX_DIR_HIST] and set -e dirprev[1] - set -g dirprev $dirprev $previous + set -g -a dirprev $previous set -e dirnext set -g __fish_cd_direction prev end diff --git a/share/functions/cdh.fish b/share/functions/cdh.fish index 773db10ba..c6a56176e 100644 --- a/share/functions/cdh.fish +++ b/share/functions/cdh.fish @@ -26,7 +26,7 @@ function cdh --description "Menu based cd command" set -l uniq_dirs for dir in $all_dirs[-1..1] if not contains $dir $uniq_dirs - set uniq_dirs $uniq_dirs $dir + set -a uniq_dirs $dir end end diff --git a/share/functions/help.fish b/share/functions/help.fish index a31d6af04..16cd17603 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -10,9 +10,9 @@ function help --description 'Show help for the fish shell' set -l fish_help_item $argv[1] set -l help_topics syntax completion editor job-control todo bugs history killring help - set help_topics $help_topics color prompt title variables builtin-overview changes expand - set help_topics $help_topics expand-variable expand-home expand-brace expand-wildcard - set help_topics $help_topics expand-command-substitution expand-process + set -a help_topics color prompt title variables builtin-overview changes expand + set -a help_topics expand-variable expand-home expand-brace expand-wildcard + set -a help_topics expand-command-substitution expand-process # # Find a suitable browser for viewing the help pages. This is needed diff --git a/share/functions/history.fish b/share/functions/history.fish index bfe2651ad..7e90caa99 100644 --- a/share/functions/history.fish +++ b/share/functions/history.fish @@ -19,14 +19,14 @@ function history --description "display or manipulate interactive command histor set -l cmd history set -l options --exclusive 'c,e,p' --exclusive 'S,D,M,V,C' --exclusive 't,T' - set options $options 'h/help' 'c/contains' 'e/exact' 'p/prefix' - set options $options 'C/case-sensitive' 'z/null' 't/show-time=?' 'n#max' + set -a options 'h/help' 'c/contains' 'e/exact' 'p/prefix' + set -a options 'C/case-sensitive' 'z/null' 't/show-time=?' 'n#max' # This long option is deprecated and here solely for legacy compatibility. People should use # -t or --show-time now. - set options $options 'T-with-time=?' + set -a options 'T-with-time=?' # The following options are deprecated and will be removed in the next major release. # Note that they do not have usable short flags. - set options $options 'S-search' 'D-delete' 'M-merge' 'V-save' 'R-clear' + set -a options 'S-search' 'D-delete' 'M-merge' 'V-save' 'R-clear' argparse -n $cmd $options -- $argv or return diff --git a/share/functions/ls.fish b/share/functions/ls.fish index 4a6b0db3d..a51b99c8d 100644 --- a/share/functions/ls.fish +++ b/share/functions/ls.fish @@ -6,7 +6,7 @@ if command ls --version >/dev/null ^/dev/null function ls --description "List contents of directory" set -l param --color=auto if isatty 1 - set param $param --indicator-style=classify + set -a param --indicator-style=classify end command ls $param $argv end diff --git a/share/functions/pushd.fish b/share/functions/pushd.fish index 0ccf01af9..52af5c466 100644 --- a/share/functions/pushd.fish +++ b/share/functions/pushd.fish @@ -77,6 +77,6 @@ function pushd --description 'Push directory to stack' end # argv[1] is a directory - set -g dirstack $PWD $dirstack + set -g -p dirstack $PWD cd $argv[1] end diff --git a/share/functions/realpath.fish b/share/functions/realpath.fish index 3dc17451f..4ae3b15c8 100644 --- a/share/functions/realpath.fish +++ b/share/functions/realpath.fish @@ -23,8 +23,8 @@ end function realpath -d "return an absolute path without symlinks" set -l options 'h/help' 'q/quiet' 'V-version' 's/strip' 'N-no-symlinks' 'z/zero' - set options $options 'e/canonicalize-existing' 'm/canonicalize-missing' 'L/logical' 'P/physical' - set options $options 'R-relative-to=' 'B-relative-base=' + set -a options 'e/canonicalize-existing' 'm/canonicalize-missing' 'L/logical' 'P/physical' + set -a options 'R-relative-to=' 'B-relative-base=' argparse -n realpath --min-args=1 $options -- $argv or return diff --git a/share/functions/string.fish b/share/functions/string.fish index 799258217..72cb67a62 100644 --- a/share/functions/string.fish +++ b/share/functions/string.fish @@ -14,7 +14,7 @@ if not contains string (builtin -n) set -g __is_launched_without_string 1 end end - set PATH $__fish_bin_dir $PATH + set -p PATH $__fish_bin_dir set string_cmd string \'$argv\' if fish -c 'contains string (builtin -n)' diff --git a/share/functions/umask.fish b/share/functions/umask.fish index 1ae450372..d6147d680 100644 --- a/share/functions/umask.fish +++ b/share/functions/umask.fish @@ -87,9 +87,9 @@ function __fish_umask_parse string match -q '*u*' $scope and set scopes_to_modify 1 string match -q '*g*' $scope - and set scopes_to_modify $scopes_to_modify 2 + and set -a scopes_to_modify 2 string match -q '*o*' $scope - and set scopes_to_modify $scopes_to_modify 3 + and set -a scopes_to_modify 3 string match -q '*a*' $scope and set scopes_to_modify 1 2 3