Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a better approach than using readlink -f #9

Open
kaushalmodi opened this issue Aug 26, 2015 · 3 comments
Open

Use a better approach than using readlink -f #9

kaushalmodi opened this issue Aug 26, 2015 · 3 comments

Comments

@kaushalmodi
Copy link
Owner

#8 (comment)

@kaushalmodi
Copy link
Owner Author

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
Copy link

ninrod commented Nov 1, 2016

Hi @kaushalmodi. Maybe you are looking for this:

SCRIPTPATH=$(cd $(dirname $0); pwd -P) && cd $SCRIPTPATH

@kaushalmodi
Copy link
Owner Author

kaushalmodi commented Nov 1, 2016

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants