]> gitweb.fluxo.info Git - inception.git/commitdiff
Set dir and base names depending on the way the program was called
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 24 Feb 2018 17:31:48 +0000 (14:31 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 24 Feb 2018 17:31:48 +0000 (14:31 -0300)
infection

index e7d514ebb96de7dc54087c1e370115b04d11b124..fa364b08ec9f7d0d40b13681ad12b3512c7fce8b 100755 (executable)
--- 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