Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make clean.sh scripts executable from any directory#730

Open
Eshaan-byte wants to merge 2 commits intoprecice:developfrom
Eshaan-byte:fix/clean-scripts-any-directory
Open

Make clean.sh scripts executable from any directory#730
Eshaan-byte wants to merge 2 commits intoprecice:developfrom
Eshaan-byte:fix/clean-scripts-any-directory

Conversation

Copy link

Eshaan-byte commented Feb 27, 2026

Summary

Extends the fix from #716 to the remaining case-level clean.sh scripts and one non-symlinked clean-tutorial.sh.

  • Added SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" and cd "$SCRIPT_DIR" to all 111 case-level clean.sh files
  • Applied the same fix to partitioned-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)
  • Added missing set -e -u to flow-around-controlled-moving-cylinder/solid-python/clean.sh for consistency

Closes #667

Test plan

  • Run ../clean-tutorial.sh from inside a case directory (e.g. quickstart/fluid-openfoam/)
  • Run ./fluid-openfoam/clean.sh from a tutorial directory (e.g. quickstart/)
  • Run clean-all.sh from the repository root
  • Verify all three work without errors

Checklist

  • I added a summary of any user-facing changes (compared to the last release) in the changelog-entries/.md.
  • I will remember to squash-and-merge, providing a useful summary of the changes of this PR.

Eshaan-byte added 2 commits February 28, 2026 00:33
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
MakisH added the GSoC Contributed in the context of the Google Summer of Code label Feb 27, 2026
Copy link
Member

MakisH commented Feb 27, 2026 *
edited
Loading

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 ../tools/cleaning-tools.sh?

Also: No need for an issue before a PR, if the PR is anyway on the way.

Eshaan-byte reacted with thumbs up emoji

Copy link
Author

Eshaan-byte commented Feb 27, 2026

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):
#!/usr/bin/env sh
set -e -u

. "$(dirname "$0")/../../tools/cleaning-tools.sh"

clean_openfoam .
cleaning-tools.sh (add at the top):

cd "$(cd "$(dirname "$0")" && pwd)"
This way no extra lines are added to clean.sh -- it stays the same size. Would this approach work for you?

Copy link
Contributor

PranjalManhgaye commented Feb 27, 2026 *
edited
Loading

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:
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"

idea was to make the files slim,
This avoids depending solely on the sourced file to set up the correct working directory and makes each script self-contained and robust across environments.
thanks you pointed next time , taking a bit more time to check the actual PR implementation helps avoid that confusion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

GSoC Contributed in the context of the Google Summer of Code

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Cleaning scripts are not callable from the root directory

3 participants