فهرست منبع

fix for profile detection

this should now work no matter how the script is called (including symlinks) on both Mac and Linux.
+ Storing and restoring the original working directory to prevent problems in certain circumstances.
earthlng 7 سال پیش
والد
کامیت
500c129d48
1فایلهای تغییر یافته به همراه14 افزوده شده و 3 حذف شده
  1. 14 3
      updater.sh

+ 14 - 3
updater.sh

@@ -2,14 +2,22 @@
 
 
 ### ghacks-user.js updater for Mac/Linux
 ### ghacks-user.js updater for Mac/Linux
 ## author: @overdodactyl
 ## author: @overdodactyl
-## version: 1.0
+## version: 1.1
 
 
 ghacksjs="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js"
 ghacksjs="https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js"
 
 
-cd "`dirname $0`"
-
 echo -e "\nThis script should be run from your Firefox profile directory.\n"
 echo -e "\nThis script should be run from your Firefox profile directory.\n"
 
 
+currdir=$(pwd)
+
+## get the full path of this script (greadlink for Mac, readlink for Linux)
+scriptfullpath=$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")
+
+## change directory to the Firefox profile directory
+cd "$(dirname "${scriptfullpath}")"
+
+echo -e "Updating the user.js for Firefox profile:\n$(pwd)\n"
+
 if [ -e user.js ]; then
 if [ -e user.js ]; then
   echo "Your current user.js file for this profile will be backed up and the latest ghacks version from github will take its place."
   echo "Your current user.js file for this profile will be backed up and the latest ghacks version from github will take its place."
   echo -e "\nIf currently using the ghacks user.js, please compare versions:"
   echo -e "\nIf currently using the ghacks user.js, please compare versions:"
@@ -42,3 +50,6 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
 else
 else
   echo "Process aborted"
   echo "Process aborted"
 fi
 fi
+
+## change directory back to the original working directory
+cd "${currdir}"