Answer the question
In order to leave comments, you need to log in
A small question about the sh-script?
There is some script vars.sh : export PATH=`pwd`/bin:$PATH
Working with it looks like this:
$ cd /some/working/dir<br/>
$ great_app args<br/>
error: not found!<br/>
$ cd /some/interesting/dir<br/>
$ ls bin<br/>
great_app<br/>
$ . vars.sh<br/>
$ cd /some/working/dir<br/>
$ great_app args<br/>
i'm working!<br/>
$ cd /some/working/dir<br/>
$ . /some/interesting/dir/vars.sh<br/>
$ great_app args<br/>
i'm working!<br/>
Answer the question
In order to leave comments, you need to log in
Better simpler - make yourself an alias or a function in ~/.bashrc.
Unfortunately, I did not fully understand the author. Would it be enough to add ./bin to PATNA?
I do this: at the beginning of the script, I set up the MY_DIR variable:
MY_DIR=`readlink -f "$(dirname "$0")"`
Now it will contain the full path to the script, regardless of where it was launched from. Run other scripts already relative to this directory. I think this is preferable to modifying PATH (albeit temporarily).
Yes, please note: all quotes are required.
What an old horror question, nevertheless I will offer my own version:
SCRIPT_NAME=${0##*/}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
FULL_SCRIPT_NAME=${SCRIPT_DIR}/${SCRIPT_NAME}
echo ${FULL_SCRIPT_NAME}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question