Use posix stderr redirection (2> instead of ^)

Fish is deprecating `^` as a shortcut for stderr redirection.
Replace with the more common and compatible `2>`.

Fixes #609
This commit is contained in:
Itzik Ephraim 2018-06-08 23:58:16 +03:00
parent 112fb3dbc2
commit a6a67be60b
18 changed files with 42 additions and 42 deletions

View File

@ -34,7 +34,7 @@ fish install --path=~/.local/share/omf --config=~/.config/omf
You can verify the integrity of the downloaded installer by verifying the script against [this checksum](bin/install.sha256): You can verify the integrity of the downloaded installer by verifying the script against [this checksum](bin/install.sha256):
``` ```
06844ca6876fac0ea949c8089d8c5f71e14b69d2bb1dc41f1d0677250a1c62e1 install 434264c56e3a7bb74733d9b293d72403c404e0a0bded3e632433d391d302504e install
``` ```
You can also install Oh My Fish with Git or with an offline source tarball downloaded from the [releases page][releases]: You can also install Oh My Fish with Git or with an offline source tarball downloaded from the [releases page][releases]:

View File

@ -186,7 +186,7 @@ function install_from_github
if test $OMF_CHANNEL = stable if test $OMF_CHANNEL = stable
# Get the commit for the latest release. # Get the commit for the latest release.
set -l hash (command git --git-dir "$OMF_PATH/.git" --work-tree "$OMF_PATH" rev-list --tags='v*' --max-count=1 ^ /dev/null) set -l hash (command git --git-dir "$OMF_PATH/.git" --work-tree "$OMF_PATH" rev-list --tags='v*' --max-count=1 2> /dev/null)
# Get the release tag. # Get the release tag.
and set -l tag (command git --git-dir "$OMF_PATH/.git" --work-tree "$OMF_PATH" describe --tags $hash) and set -l tag (command git --git-dir "$OMF_PATH/.git" --work-tree "$OMF_PATH" describe --tags $hash)
# Checkout the release. # Checkout the release.
@ -365,11 +365,11 @@ function uninstall_omf
is_install_dir "$OMF_PATH" is_install_dir "$OMF_PATH"
or abort "No installation detected at $OMF_PATH" or abort "No installation detected at $OMF_PATH"
say (set_color -o red ^ /dev/null)"This will uninstall Oh My Fish and all plugins and themes from $OMF_PATH."(set_color normal ^ /dev/null) say (set_color -o red 2> /dev/null)"This will uninstall Oh My Fish and all plugins and themes from $OMF_PATH."(set_color normal 2> /dev/null)
# If we installed the bootstrap to the user's config, let them know they need to remove it themselves. # If we installed the bootstrap to the user's config, let them know they need to remove it themselves.
if begin; test -f "$FISH_CONFIG/config.fish"; and grep -q OMF_PATH "$FISH_CONFIG/config.fish"; end if begin; test -f "$FISH_CONFIG/config.fish"; and grep -q OMF_PATH "$FISH_CONFIG/config.fish"; end
say (set_color -o ^ /dev/null)"Your configuration will not be modified. You may need to remove Oh My Fish startup code from $FISH_CONFIG/config.fish."(set_color normal ^ /dev/null) say (set_color -o 2> /dev/null)"Your configuration will not be modified. You may need to remove Oh My Fish startup code from $FISH_CONFIG/config.fish."(set_color normal 2> /dev/null)
end end
confirm_yes "Are you sure you want to continue?" confirm_yes "Are you sure you want to continue?"
@ -420,7 +420,7 @@ function backup_file -a file_path
say "Existent $file found at $path" say "Existent $file found at $path"
say "↳ Moving to $backup_file" say "↳ Moving to $backup_file"
if not command cp "$file_path" $backup_file ^/dev/null if not command cp "$file_path" $backup_file 2> /dev/null
abort "Could not backup $file_path" abort "Could not backup $file_path"
end end
@ -441,7 +441,7 @@ function restore_backup_file -a file_path
if confirm "Would you like to restore it (overwrite existing)?" if confirm "Would you like to restore it (overwrite existing)?"
say "Restoring backup file to $path/$file" say "Restoring backup file to $path/$file"
command mv "$backup_file_path" "$path/$file" ^/dev/null command mv "$backup_file_path" "$path/$file" 2> /dev/null
or abort "Could not restore backup $backup_file_path" or abort "Could not restore backup $backup_file_path"
end end
end end
@ -467,7 +467,7 @@ function sane_environment_check
or abort (which sort)" is not a sane 'sort' implementation" or abort (which sort)" is not a sane 'sort' implementation"
debug "Checking for a working AWK interpreter" debug "Checking for a working AWK interpreter"
cmd awk 'BEGIN{exit 42;}' < /dev/null ^ /dev/null cmd awk 'BEGIN{exit 42;}' < /dev/null 2> /dev/null
if not test $status -eq 42 if not test $status -eq 42
abort (which awk)" does not look like an AWK interpreter." abort (which awk)" does not look like an AWK interpreter."
end end
@ -501,7 +501,7 @@ end
# Gets the version of Git installed. # Gets the version of Git installed.
function get_git_version function get_git_version
type -f git > /dev/null ^ /dev/null type -f git > /dev/null 2> /dev/null
and command git --version | command cut -d' ' -f3 and command git --version | command cut -d' ' -f3
end end
@ -516,7 +516,7 @@ end
# Checks if OMF is set up properly and working. # Checks if OMF is set up properly and working.
function is_omf_loaded function is_omf_loaded
command fish -c "omf --version" > /dev/null ^&1 command fish -c "omf --version" > /dev/null 2>&1
end end
@ -561,7 +561,7 @@ function assert_cmds
set -l cmds awk basename cp cut date dirname env fish fold head mkdir mv readlink rm sed sort tar tr which set -l cmds awk basename cp cut date dirname env fish fold head mkdir mv readlink rm sed sort tar tr which
for cmd in $cmds for cmd in $cmds
type -f $cmd > /dev/null ^ /dev/null type -f $cmd > /dev/null 2> /dev/null
or abort "Missing required command: $cmd" or abort "Missing required command: $cmd"
debug "Command '$cmd' is "(which $cmd) debug "Command '$cmd' is "(which $cmd)
@ -575,14 +575,14 @@ function assert_interactive
and return and return
test -c /dev/tty -a -r /dev/tty test -c /dev/tty -a -r /dev/tty
and echo -n > /dev/tty ^ /dev/null and echo -n > /dev/tty 2> /dev/null
or abort "Running interactively, but can't read from tty (try running with --noninteractive)" or abort "Running interactively, but can't read from tty (try running with --noninteractive)"
end end
# A link-following `which` wrapper. # A link-following `which` wrapper.
function which function which
if type realpath > /dev/null ^ /dev/null if type realpath > /dev/null 2> /dev/null
realpath (command which $argv) realpath (command which $argv)
else else
command readlink (command which $argv) command readlink (command which $argv)
@ -595,7 +595,7 @@ function cmd
if set -q VERBOSE if set -q VERBOSE
command env $argv command env $argv
else else
command env $argv ^ /dev/null command env $argv 2> /dev/null
end end
end end
@ -621,9 +621,9 @@ function abort -a message code
end end
if test -n "$message" if test -n "$message"
printf "%sInstall aborted: $message%s\n" (set_color -o red ^ /dev/null) (set_color normal ^ /dev/null) >&2 printf "%sInstall aborted: $message%s\n" (set_color -o red 2> /dev/null) (set_color normal 2> /dev/null) >&2
else else
printf "%sInstall aborted%s\n" (set_color -o red ^ /dev/null) (set_color normal ^ /dev/null) >&2 printf "%sInstall aborted%s\n" (set_color -o red 2> /dev/null) (set_color normal 2> /dev/null) >&2
end end
exit $code exit $code
@ -640,7 +640,7 @@ function confirm -a message
set -q NONINTERACTIVE set -q NONINTERACTIVE
and return 1 and return 1
printf "%s$message (y/N): %s" (set_color yellow ^ /dev/null) (set_color normal ^ /dev/null) printf "%s$message (y/N): %s" (set_color yellow 2> /dev/null) (set_color normal 2> /dev/null)
read -l answer < /dev/tty read -l answer < /dev/tty
or abort "Failed to read from tty" or abort "Failed to read from tty"

View File

@ -1 +1 @@
06844ca6876fac0ea949c8089d8c5f71e14b69d2bb1dc41f1d0677250a1c62e1 install 434264c56e3a7bb74733d9b293d72403c404e0a0bded3e632433d391d302504e install

View File

@ -5,7 +5,7 @@ if not set -q OMF_CONFIG
end end
# Source custom before.init.fish file # Source custom before.init.fish file
test -f $OMF_CONFIG/before.init.fish test -f $OMF_CONFIG/before.init.fish
and source $OMF_CONFIG/before.init.fish ^/dev/null and source $OMF_CONFIG/before.init.fish 2> /dev/null
emit perf:timer:start "Oh My Fish initialisation" emit perf:timer:start "Oh My Fish initialisation"
# Read current theme # Read current theme
test -f $OMF_CONFIG/theme test -f $OMF_CONFIG/theme

View File

@ -1,7 +1,7 @@
function git_ahead -a ahead behind diverged none function git_ahead -a ahead behind diverged none
not git_is_repo; and return not git_is_repo; and return
set -l commit_count (command git rev-list --count --left-right "@{upstream}...HEAD" ^/dev/null) set -l commit_count (command git rev-list --count --left-right "@{upstream}...HEAD" 2> /dev/null)
switch "$commit_count" switch "$commit_count"
case "" case ""

View File

@ -1,6 +1,6 @@
function git_branch_name -d "Get current branch name" function git_branch_name -d "Get current branch name"
git_is_repo; and begin git_is_repo; and begin
command git symbolic-ref --short HEAD ^/dev/null; command git symbolic-ref --short HEAD 2> /dev/null;
or command git show-ref --head -s --abbrev | head -n1 ^/dev/null or command git show-ref --head -s --abbrev | head -n1 2> /dev/null
end end
end end

View File

@ -1,3 +1,3 @@
function git_is_repo -d "Check if directory is a repository" function git_is_repo -d "Check if directory is a repository"
test -d .git; or command git rev-parse --git-dir >/dev/null ^/dev/null test -d .git; or command git rev-parse --git-dir >/dev/null 2> /dev/null
end end

View File

@ -13,7 +13,7 @@ function fish-spec
end end
# Load helper file # Load helper file
source spec/helper.fish ^/dev/null source spec/helper.fish 2> /dev/null
emit all_specs_init emit all_specs_init

View File

@ -8,7 +8,7 @@ function omf.bundle.add -a type name_or_url
set -l record "$type $name_or_url" set -l record "$type $name_or_url"
if test -f $bundle if test -f $bundle
if not grep $record $bundle > /dev/null ^&1 if not grep $record $bundle > /dev/null 2>&1
echo $record >> $bundle echo $record >> $bundle
end end
else else

View File

@ -13,10 +13,10 @@ function omf.cli.help
set doc $doc_root/$command.adoc set doc $doc_root/$command.adoc
end end
set -l r (set_color normal ^ /dev/null) set -l r (set_color normal 2> /dev/null)
set -l c (set_color cyan ^ /dev/null) set -l c (set_color cyan 2> /dev/null)
set -l b (set_color --bold ^ /dev/null) set -l b (set_color --bold 2> /dev/null)
set -l u (set_color --underline ^ /dev/null) set -l u (set_color --underline 2> /dev/null)
# Format the help document for the terminal. # Format the help document for the terminal.
fold -s -w 78 $doc | sed -e " fold -s -w 78 $doc | sed -e "

View File

@ -1,6 +1,6 @@
function omf.cli.reload function omf.cli.reload
if not contains -- --force $argv if not contains -- --force $argv
if count (jobs) >/dev/null ^&1 if count (jobs) >/dev/null 2>&1
__omf.cli.reload.job_warning __omf.cli.reload.job_warning
return 1 return 1
end end

View File

@ -4,10 +4,10 @@ function omf.core.update
# If the channel isn't explicitly set and we are currently tracking a branch instead of a version, the user probably # If the channel isn't explicitly set and we are currently tracking a branch instead of a version, the user probably
# upgraded from an old version. Let them know that we will start updating to stable versions. # upgraded from an old version. Let them know that we will start updating to stable versions.
if begin; not test -f $OMF_CONFIG/channel; and command git -C "$OMF_PATH" symbolic-ref -q HEAD > /dev/null; end if begin; not test -f $OMF_CONFIG/channel; and command git -C "$OMF_PATH" symbolic-ref -q HEAD > /dev/null; end
set_color yellow --bold ^ /dev/null set_color yellow --bold 2> /dev/null
echo ">> You have been switched to the stable release channel of Oh My Fish." echo ">> You have been switched to the stable release channel of Oh My Fish."
echo ">> To switch back to the development channel, run `omf channel dev`." echo ">> To switch back to the development channel, run `omf channel dev`."
set_color normal ^ /dev/null set_color normal 2> /dev/null
end end
# Determine the remote to fetch from. # Determine the remote to fetch from.
@ -19,7 +19,7 @@ function omf.core.update
# Fetch the latest tags. # Fetch the latest tags.
command git -C "$OMF_PATH" fetch --quiet --tags $remote command git -C "$OMF_PATH" fetch --quiet --tags $remote
# Get the commit for the latest release. # Get the commit for the latest release.
and set -l hash (command git -C "$OMF_PATH" rev-list --tags='v*' --max-count=1 ^ /dev/null) and set -l hash (command git -C "$OMF_PATH" rev-list --tags='v*' --max-count=1 2> /dev/null)
# Get the release tag. # Get the release tag.
and set -l tag (command git -C "$OMF_PATH" describe --tags $hash) and set -l tag (command git -C "$OMF_PATH" describe --tags $hash)
# Checkout the release. # Checkout the release.

View File

@ -46,7 +46,7 @@ function omf.index.repositories -d 'Manage package repositories'
end end
# Before we add, do a quick ls-remote to see if the URL is a valid repo. # Before we add, do a quick ls-remote to see if the URL is a valid repo.
if not command git ls-remote --exit-code $repo_url refs/heads/$repo_branch > /dev/null ^&1 if not command git ls-remote --exit-code $repo_url refs/heads/$repo_branch > /dev/null 2>&1
echo "The remote repository could not be found." >&2 echo "The remote repository could not be found." >&2
return 1 return 1
end end

View File

@ -35,7 +35,7 @@ function __omf.packages.new.from_template -a path github user name
end)$target end)$target
end end
end end
popd >/dev/null ^&1 popd >/dev/null 2>&1
end end

View File

@ -17,7 +17,7 @@ function omf.packages.remove -a pkg
# Run uninstall hook first. # Run uninstall hook first.
omf.packages.run_hook $path uninstall omf.packages.run_hook $path uninstall
source $path/uninstall.fish ^/dev/null; source $path/uninstall.fish 2> /dev/null;
and emit uninstall_$pkg and emit uninstall_$pkg
if rm -rf $path if rm -rf $path

View File

@ -3,7 +3,7 @@ function omf.check.fish_prompt
set -l theme (cat $OMF_CONFIG/theme) set -l theme (cat $OMF_CONFIG/theme)
set -l user_functions_path (omf.xdg.config_home)/fish/functions set -l user_functions_path (omf.xdg.config_home)/fish/functions
set -l fish_prompt (readlink "$user_functions_path/$prompt_file" ^/dev/null) set -l fish_prompt (readlink "$user_functions_path/$prompt_file" 2> /dev/null)
not test -e "$fish_prompt"; and return 0 not test -e "$fish_prompt"; and return 0
contains -- "$fish_prompt" {$OMF_CONFIG,$OMF_PATH}/themes/$theme/$prompt_file contains -- "$fish_prompt" {$OMF_CONFIG,$OMF_PATH}/themes/$theme/$prompt_file

View File

@ -4,23 +4,23 @@ set -g OMF_INVALID_ARG 3
set -g OMF_UNKNOWN_ERR 4 set -g OMF_UNKNOWN_ERR 4
function omf::em function omf::em
set_color cyan ^ /dev/null set_color cyan 2> /dev/null
end end
function omf::dim function omf::dim
set_color 555 ^ /dev/null set_color 555 2> /dev/null
end end
function omf::err function omf::err
set_color red --bold ^ /dev/null set_color red --bold 2> /dev/null
end end
function omf::under function omf::under
set_color --underline ^ /dev/null set_color --underline 2> /dev/null
end end
function omf::off function omf::off
set_color normal ^ /dev/null set_color normal 2> /dev/null
end end
autoload $path/functions/{compat,core,index,packages,themes,bundle,util,repo,cli,search} autoload $path/functions/{compat,core,index,packages,themes,bundle,util,repo,cli,search}

View File

@ -14,7 +14,7 @@ function describe_basic_tests
end end
function it_install_packages function it_install_packages
set -l remove_output (omf remove apt ^/dev/null) set -l remove_output (omf remove apt 2> /dev/null)
set -l install_output (omf install apt) set -l install_output (omf install apt)
assert 0 = $status assert 0 = $status