Make clean.sh scripts executable from any directory#730
Make clean.sh scripts executable from any directory#730Eshaan-byte wants to merge 2 commits intoprecice:developfrom
Conversation
Extends the fix from precice#716 to the remaining case-level clean.sh scripts and one non-symlinked clean-tutorial.sh. - Added SCRIPT_DIR resolution and cd to all 111 case-level clean.sh - Applied the same fix to partitioned-heat-conduction-direct/clean-tutorial.sh - Added missing set -e -u to flow-around-controlled-moving-cylinder/solid-python/clean.sh Closes precice#667
|
Hi @Eshaan-byte, Similar comment as in #716: We want to keep these files as slim as possible. Would it be possible to move this (or probably a similar hack) to Also: No need for an issue before a PR, if the PR is anyway on the way. |
|
Hi @MakisH, thanks for the review! The challenge is that clean.sh sources cleaning-tools.sh via a relative path (../../tools/cleaning-tools.sh), which fails before cleaning-tools.sh even loads when called from a different directory. A possible approach to keep clean.sh slim: change the source line to resolve from $0 instead of $PWD, and let cleaning-tools.sh handle the cd. clean.sh (only the source line changes): . "$(dirname "$0")/../../tools/cleaning-tools.sh" clean_openfoam . cd "$(cd "$(dirname "$0")" && pwd)" |
|
Hi @Eshaan-byte , thanks for the suggestion ,i agree that resolving the source path using dirname "$0" fixes the issue locally. In the final merged PR #716, i applied a similar idea but made it explicit in each script so they reliably determine their own directory before sourcing anything. This ensures all cleaning scripts are truly callable from any directory, not just when sourcing a helper file. That’s the pattern that got approved — scripts use: idea was to make the files slim, |
Summary
Extends the fix from #716 to the remaining case-level
clean.shscripts and one non-symlinkedclean-tutorial.sh.SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"andcd "$SCRIPT_DIR"to all 111 case-levelclean.shfilespartitioned-heat-conduction-direct/clean-tutorial.sh(real file, not a symlink, so Make clean-tutorial.sh executable from any directory #716 didn't cover it)set -e -utoflow-around-controlled-moving-cylinder/solid-python/clean.shfor consistencyCloses #667
Test plan
../clean-tutorial.shfrom inside a case directory (e.g.quickstart/fluid-openfoam/)./fluid-openfoam/clean.shfrom a tutorial directory (e.g.quickstart/)clean-all.shfrom the repository rootChecklist
changelog-entries/<PRnumber>.md.