string.fish: use if/else. Reindent.

This commit is contained in:
Aaron Gyes 2016-07-02 11:40:22 -07:00
parent e597df70d7
commit f966248f16

View file

@ -1,25 +1,26 @@
# XXX nostring # XXX nostring
if not contains string (builtin -n) if not contains string (builtin -n)
function string function string
if not set -q __is_launched_without_string if not set -q __is_launched_without_string
if status --is-interactive if status --is-interactive
# We've been autoloaded after fish < 2.3.0 upgraded to >= 2.3.1 - no string builtin # We've been autoloaded after fish < 2.3.0 upgraded to >= 2.3.1 - no string builtin
set_color --bold >&2 set_color --bold >&2
echo "Fish has been upgraded, and the scripts on your system are not compatible" >&2 echo "Fish has been upgraded, and the scripts on your system are not compatible" >&2
echo "with this prior instance of fish. You can probably run:" >&2 echo "with this prior instance of fish. You can probably run:" >&2
set_color green >&2 set_color green >&2
echo -e "\n exec fish" >&2 echo -e "\n exec fish" >&2
set_color normal >&2 set_color normal >&2
echo "… to replace this process with a new one in-place." >&2 echo "… to replace this process with a new one in-place." >&2
set -g __is_launched_without_string 1 set -g __is_launched_without_string 1
end end
end end
# We hope that in $__fish_bin_path is a newer fish that can do `string` for us. set PATH $__fish_bin_dir $PATH
set string_cmd string \'$argv\'
set PATH $__fish_bin_dir $PATH if fish -c 'contains string (builtin -n)'
set string_cmd string \'$argv\' fish -c "$string_cmd"
fish -c 'contains string (builtin -n)' else
and fish -c "$string_cmd" return 127
or return 127 end
end end
end end