From 6ec605f461cb506991c691426b10b821036ab5dd Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 28 Jun 2013 13:57:16 +0200 Subject: [PATCH] New build of unfinished main executable, just for fun... --- bin/dotify | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/bin/dotify b/bin/dotify index 4ddba78..c992949 100755 --- a/bin/dotify +++ b/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 $?