kaushalmodi / .emacs.d

My emacs configuration
MIT License
262 stars 49 forks source link

Use a better approach than using `readlink -f` #9

Open kaushalmodi opened 9 years ago

kaushalmodi commented 9 years ago

https://github.com/kaushalmodi/.emacs.d/issues/8#issuecomment-134997010

kaushalmodi commented 9 years ago

It's funny that the moment I start searching for a way to get the name of the script being executed, I end up on the same source from where I learnt about readlink -f: http://tipsarea.com/2013/04/11/how-to-get-the-script-path-name-in-cshtcsh/

ninrod commented 7 years ago

Hi @kaushalmodi. Maybe you are looking for this:

SCRIPTPATH=$(cd $(dirname $0); pwd -P) && cd $SCRIPTPATH
kaushalmodi commented 7 years ago

@ninrod I do use $0 and dirname but not in the same way. I need to handle the cases where the script is executed as source foo.csh vs ./foo.csh. Also, I wrap the script in a tcsh alias. I need to get the exact physical file name in that case, and that's why I need readlink.