From 5423c61c1cdf576ac00ff63e16c9e3348758cd8c Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 28 Jun 2013 13:55:23 +0200 Subject: [PATCH] Update locate-* functions to use global variables --- src/lib/internals.sh | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/lib/internals.sh b/src/lib/internals.sh index b608ff6..733231f 100644 --- a/src/lib/internals.sh +++ b/src/lib/internals.sh @@ -1,39 +1,31 @@ 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() {