/
Shell scripts under tools folder using relative paths

Shell scripts under tools folder using relative paths

The way shell scripts under tools/ folder are using relative paths results in absolutely undesired behavior, when they are executed by other scripts.

In following working example current directory will be "/path/to/in-portal/tools", which is correct.

Working example
cd /path/to/in-portal/tools
./fix_perms.sh

In following working example current directory will be "/path/to/in-portal", which is not correct.

Not working example
cd /path/to/in-portal
./tools/fix_perms.sh

After digging a bit on the Internet I've found a solution, that finds absolute path to folder, where executed script is actually located:

SCRIPT_FOLDER=`cd $(dirname $0); pwd`

Also these scripts missing #!/bin/sh at the top of the script.

Related Tasks

Error rendering macro 'jira' : Unable to locate Jira server for this macro. It may be due to Application Link configuration.