Minor tweaks to vared function

darcs-hash:20070208170118-ac50b-76ea318d47de28a4437ecf0a50daea2c617017ea.gz
This commit is contained in:
axel 2007-02-09 03:01:18 +10:00
parent 100355c3c1
commit 7118269e4b

View File

@ -18,25 +18,25 @@ function vared --description "Edit variable value"
case '*'
if test (count $$argv ) -lt 2
set init ''
set -l init ''
if test $$argv
set init $$argv
end
set prompt 'set_color green; echo '$argv'; set_color normal; echo "> "'
read -p $prompt -c $init tmp
set -l prompt 'set_color green; echo '$argv'; set_color normal; echo "> "'
if read -p $prompt -c $init tmp
# If variable already exists, do not add any
# switches, so we don't change export rules. But
# if it does not exist, we make the variable
# global, so that it will not die when this
# function dies
# If variable already exists, do not add any
# switches, so we don't change export rules. But
# if it does not exist, we make the variable
# global, so that it will not die when this
# function dies
if test $$argv
set -- $argv $tmp
else
set -g -- $argv $tmp
if test $$argv
set $argv $tmp
else
set -g $argv $tmp
end
end
else
printf (_ '%s: %s is an array variable. Use %svared%s %s[n] to edit the n:th element of %s\n') $argv (set_color $fish_color_command) (set_color $fish_color_normal) vared $argv $argv