mirror of
https://github.com/jimeh/dotify.git
synced 2026-02-19 10:06:39 +00:00
Update locate-* functions to use global variables
This commit is contained in:
@@ -1,39 +1,31 @@
|
|||||||
locate-dotfile() {
|
locate-dotfile() {
|
||||||
local dotfile
|
|
||||||
if [ -n "$DOTFILE" ]; then
|
if [ -n "$DOTFILE" ]; then
|
||||||
dotfile="$DOTFILE"
|
if [ ! -f "$DOTFILE" ]; then
|
||||||
if [ ! -f "$dotfile" ]; then
|
echo "ERROR: \"$DOTFILE\" does not exist." >&2
|
||||||
echo "ERROR: \"$dotfile\" does not exist." >&2
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
elif [ -f "$(pwd)/Dotfile" ]; then
|
elif [ -f "$(pwd)/Dotfile" ]; then
|
||||||
dotfile="$(pwd)/Dotfile"
|
DOTFILE="$(pwd)/Dotfile"
|
||||||
else
|
else
|
||||||
echo "ERROR: \"$(pwd)\" does not have a Dotfile." >&2
|
echo "ERROR: \"$(pwd)\" does not have a Dotfile." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$dotfile"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
locate-target() {
|
locate-target() {
|
||||||
local target
|
if [ -n "$TARGET" ]; then
|
||||||
if [ -n "$DOTFILE" ]; then
|
if [ ! -d "$TARGET" ]; then
|
||||||
target="$TARGET"
|
echo "ERROR: Target \"$TARGET\" is not a directory." >&2
|
||||||
if [ ! -d "$target" ]; then
|
|
||||||
echo "ERROR: Target \"$target\" is not a directory." >&2
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
elif [ -n "$HOME" ] && [ -d "$HOME" ]; then
|
elif [ -n "$HOME" ] && [ -d "$HOME" ]; then
|
||||||
target="$HOME"
|
TARGET="$HOME"
|
||||||
elif [ -d ~ ]; then
|
elif [ -d ~ ]; then
|
||||||
target=~
|
TARGET=~
|
||||||
else
|
else
|
||||||
echo "ERROR: Your \$HOME folder could not be found." >&2
|
echo "ERROR: Your \$HOME folder could not be found." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$target"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create-rootlink() {
|
create-rootlink() {
|
||||||
|
|||||||
Reference in New Issue
Block a user