use the new set -a and set -p in our scripts

This commit is contained in:
Kurtis Rader 2017-08-04 18:02:24 -07:00
parent 67de733b9b
commit 8b79f4e5c9
23 changed files with 63 additions and 67 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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_*

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)'

View file

@ -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