I need some help understanding following shell script line,
apphome = "`cd \`dirname $0\` && pwd && cd - >/dev/null`"
All I understand is, this is creating a variable called apphome.
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.
This is not a valid shell code.
The shell don’t allow spaces around
=For the rest, while this seems broken, it try to
cdto the dir of the script itself, display the current dir & finallycdback to the latestcdplace redirecting his standard outputSTDOUTto the/dev/nulltrash-bin (that’s makes not any sense,cddisplay only on standard errorSTDERRwhen it fails, never onSTDOUT)If you want to do this in a proper a simple way :
That’s all you need.
NOTE
The backquote
`
is used in the old-style command substitution, e.g.
The
syntax is recommended instead. Backslash handling inside $() is less surprising, and $() is easier to nest. See http://mywiki.wooledge.org/BashFAQ/082