mirror of
https://github.com/jimeh/dotify.git
synced 2026-02-19 01:56:39 +00:00
New build of unfinished main executable, just for fun...
This commit is contained in:
31
bin/dotify
31
bin/dotify
@@ -117,41 +117,33 @@ trim() {
|
||||
#
|
||||
|
||||
locate-dotfile() {
|
||||
local dotfile
|
||||
if [ -n "$DOTFILE" ]; then
|
||||
dotfile="$DOTFILE"
|
||||
if [ ! -f "$dotfile" ]; then
|
||||
echo "ERROR: \"$dotfile\" does not exist." >&2
|
||||
if [ ! -f "$DOTFILE" ]; then
|
||||
echo "ERROR: \"$DOTFILE\" does not exist." >&2
|
||||
return 1
|
||||
fi
|
||||
elif [ -f "$(pwd)/Dotfile" ]; then
|
||||
dotfile="$(pwd)/Dotfile"
|
||||
DOTFILE="$(pwd)/Dotfile"
|
||||
else
|
||||
echo "ERROR: \"$(pwd)\" does not have a Dotfile." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$dotfile"
|
||||
}
|
||||
|
||||
locate-target() {
|
||||
local target
|
||||
if [ -n "$DOTFILE" ]; then
|
||||
target="$TARGET"
|
||||
if [ ! -d "$target" ]; then
|
||||
echo "ERROR: Target \"$target\" is not a directory." >&2
|
||||
if [ -n "$TARGET" ]; then
|
||||
if [ ! -d "$TARGET" ]; then
|
||||
echo "ERROR: Target \"$TARGET\" is not a directory." >&2
|
||||
return 1
|
||||
fi
|
||||
elif [ -n "$HOME" ] && [ -d "$HOME" ]; then
|
||||
target="$HOME"
|
||||
TARGET="$HOME"
|
||||
elif [ -d ~ ]; then
|
||||
target=~
|
||||
TARGET=~
|
||||
else
|
||||
echo "ERROR: Your \$HOME folder could not be found." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$target"
|
||||
}
|
||||
|
||||
create-rootlink() {
|
||||
@@ -283,7 +275,7 @@ dotify-install() {
|
||||
if [ -z "$target" ]; then return 1; fi
|
||||
|
||||
parse-dotfile "$dotfile" "$target"
|
||||
return "$?"
|
||||
return $?
|
||||
}
|
||||
|
||||
|
||||
@@ -325,16 +317,19 @@ for arg in "$@"; do
|
||||
fi
|
||||
done
|
||||
|
||||
# Show help and exit if help arguments or command are given.
|
||||
if [ -n "$HELP" ] || [ "$command" == "help" ]; then
|
||||
dotify-help
|
||||
exit
|
||||
fi
|
||||
|
||||
# Show version info and exit if version arguments or command are given.
|
||||
if [ -n "$VERSION" ] || [ "$command" == "version" ]; then
|
||||
dotify-help | head -1
|
||||
exit
|
||||
fi
|
||||
|
||||
# Deal with the commands.
|
||||
case "$command" in
|
||||
"info" )
|
||||
dotify-info
|
||||
@@ -344,5 +339,5 @@ case "$command" in
|
||||
;;
|
||||
esac
|
||||
|
||||
exit "$?"
|
||||
exit $?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user