Skip to content
Snippets Groups Projects

Fix unexpected script_path behaviour

Merged hashworks requested to merge hashworks/archiso:fix/buildScriptPath into master

When one calls the build.sh scripts with bash instead of the shebang $script_path contains the filepath, not the parent dir:

# cd /path
# grep -A2 script_path= build.sh
script_path=$(readlink -f "${0%/*}")
echo "$script_path"
exit 0
# ./build.sh
/path
# bash build.sh
/path/build.sh

This commit fixes that:

# grep -A2 script_path= build.sh
script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && pwd )"
echo "$script_path"
exit 0
# ./build.sh
/path
# bash build.sh
/path

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading