How can I determine the name of the Bash script file inside the script itself?
Like if my script is in file runme.sh, then how would I make it to display ‘You are running runme.sh’ message without hardcoding that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For reading through a symlink1, which is usually not what you want (you usually don’t want to confuse the user this way), try:
IMO, that’ll produce confusing output. "I ran foo.sh, but it’s saying I’m running bar.sh!? Must be a bug!" Besides, one of the purposes of having differently-named symlinks is to provide different functionality based on the name it’s called as (think gzip and gunzip on some platforms).
1 That is, to resolve symlinks such that when the user executes
foo.shwhich is actually a symlink tobar.sh, you wish to use the resolved namebar.shrather thanfoo.sh.