Ditch -F option in ln and simplify code introduced in #231.

ln -F is relevant only when the target is a directory, in which
case `ln` will delete the directory so that the link can occur.

In fisherman, we use links in only two places:

1. Linking files into .config/fish/{functions,completions}, and
2. Linking local plugins into the .config/fisherman

If my calculations are correct, we don't need -F in either case.

Both {functions/completions} never contain directories, so (1)
is probably safe. The fisherman config only contains directories
to installed plugins, so not using -F actually prevents the user
from overwriting a plugin currently installed with a local plugin.
This commit is contained in:
Jorge Bucaran 2016-04-27 02:05:04 +09:00
parent 92242e7aa8
commit 227c2738b8
No known key found for this signature in database
GPG key ID: E54BA3C0E646DB30
2 changed files with 10 additions and 15 deletions

View file

@ -1,5 +1,5 @@
function fisher
set -g fisher_version "2.1.11"
set -g fisher_version "2.1.12"
set -g fisher_spinners ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏
function __fisher_show_spinner
@ -39,12 +39,6 @@ function fisher
set -g fisher_bundle "$fish_config/fishfile"
end
if test (uname -s) = "OpenBSD"
set ln_flags = "-sf"
else
set ln_flags = "-sfF"
end
if not command mkdir -p "$fish_config/"{conf.d,functions,completions} "$fisher_config" "$fisher_cache"
__fisher_log error "
I couldn't create the fisherman configuration.
@ -374,7 +368,7 @@ function __fisher_plugin_fetch_items
end
if test -d "$i"
command ln $ln_flags "$i" "$fisher_config/$names[1]"
command ln -sf "$i" "$fisher_config/$names[1]"
set links $links "$names[1]"
continue
end
@ -384,7 +378,7 @@ function __fisher_plugin_fetch_items
if test -z "$names[2]"
if test -d "$source"
if test -L "$source"
command ln $ln_flags "$source" "$fisher_config"
command ln -sf "$source" "$fisher_config"
else
command cp -rf "$source" "$fisher_config"
end
@ -619,7 +613,8 @@ function __fisher_plugin_enable -a path
set -l target "$fish_config/$dir/$base"
command ln $ln_flags "$file" "$target"
command ln -sf "$file" "$target"
builtin source "$target"
if test "$base" = "set_color_custom.fish"
@ -630,19 +625,19 @@ function __fisher_plugin_enable -a path
for file in $path/conf.d/*.{py,awk}
set -l base (basename "$file")
command ln $ln_flags "$file" "$fish_config/conf.d/$base"
command ln -sf "$file" "$fish_config/conf.d/$base"
end
for file in $path/{functions/,}*.{py,awk}
set -l base (basename "$file")
command ln $ln_flags "$file" "$fish_config/functions/$base"
command ln -sf "$file" "$fish_config/functions/$base"
end
for file in $path/conf.d/*.fish
set -l base (basename "$file")
set -l target "$fish_config/conf.d/$base"
command ln $ln_flags "$file" "$target"
command ln -sf "$file" "$target"
builtin source "$target"
end
@ -650,7 +645,7 @@ function __fisher_plugin_enable -a path
set -l base (basename "$file")
set -l target "$fish_config/completions/$base"
command ln $ln_flags "$file" "$target"
command ln -sf "$file" "$target"
builtin source "$target"
end

View file

@ -1,7 +1,7 @@
{
"name": "fisherman",
"description": "fish plugin manager",
"version": "2.1.11",
"version": "2.1.12",
"author": "Jorge Bucaran",
"homepage": "https://github.com/fisherman/fisherman",
"bugs": "https://github.com/fisherman/fisherman/issues",