aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-02-24 14:31:48 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-02-24 14:31:48 -0300
commit81143eb7542d625c13cf01c0929d9644fa9378df (patch)
treea74ff451b9e025cc5d1ed07644fdf4846d76c5f1
parent26a44411ce183fb8a1060d3db1e302297cdafe83 (diff)
downloadinception-81143eb7542d625c13cf01c0929d9644fa9378df.tar.gz
inception-81143eb7542d625c13cf01c0929d9644fa9378df.tar.bz2
Set dir and base names depending on the way the program was called
-rwxr-xr-xinfection19
1 files changed, 13 insertions, 6 deletions
diff --git a/infection b/infection
index e7d514e..fa364b0 100755
--- a/infection
+++ b/infection
@@ -5,8 +5,6 @@
# Parameters
BASENAME="`basename $0`"
-DIRNAME="$(cd `dirname $0` &> /dev/null && pwd)"
-SHORTNAME="$(echo $DIRNAME | sed -e "s|$HOME/||")"
EXCLUDES="--exclude=local --exclude=stowpkg/tree"
DATE="`date +%Y%m%d%I%M%S`"
BACKUPS="$HOME/.backups/$DATE"
@@ -22,14 +20,23 @@ function infection_usage {
# Initialize
function infection_init {
+ # Set dir and base names depending on the way the program was called (symlink or direct)
+ if [ "$(cd `dirname $0` &> /dev/null && dirname `pwd`)" == "inception" ]; then
+ DIRNAME="$(cd `dirname $0/..` &> /dev/null && pwd)"
+ else
+ DIRNAME="$(cd `dirname $0` &> /dev/null && pwd)"
+ fi
+
+ SHORTNAME="$(echo $DIRNAME | sed -e "s|$HOME/||")"
+
(
# Check if we were called correctly. Program should be called
# from the toplevel repository symlink and not from it's own
# repository
- if [ ! -d "$DIRNAME/inception" ]; then
- echo "Please call me using $DIRNAME/infection"
- exit 1
- fi
+ #if [ ! -d "$DIRNAME/inception" ]; then
+ # echo "Please call me using $DIRNAME/infection"
+ # exit 1
+ #fi
# Check if repo is inside $HOME
if [ "$DIRNAME" != "$HOME/$SHORTNAME" ]; then