Skip to content

Comments

Make clean-tutorial.sh executable from any directory#716

Merged
MakisH merged 5 commits intoprecice:developfrom
PranjalManhgaye:fix-clean-scripts
Feb 23, 2026
Merged

Make clean-tutorial.sh executable from any directory#716
MakisH merged 5 commits intoprecice:developfrom
PranjalManhgaye:fix-clean-scripts

Conversation

@PranjalManhgaye
Copy link
Contributor

@PranjalManhgaye PranjalManhgaye commented Feb 21, 2026

Summary

This PR fixes the issue where cleaning scripts were not callable when executed from the repository root directory.

Previously, the scripts assumed execution from their local tutorial directories, which caused path resolution errors when run from the root. This made repository-wide cleanup inconvenient.

Changes Made

  • Updated cleaning script logic to correctly resolve script locations.
  • Adjusted relative paths so the scripts function independently of the current working directory.
  • Ensured compatibility when executed from both:
    • Tutorial subdirectories
    • Repository root

Verification

  • Executed the cleaning scripts from their respective directories.
  • Executed the same scripts from the repository root.
  • Confirmed that cleanup operations worked correctly in both cases.

Related Issue

Related to #667

Checklist

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

PranjalManhgaye and others added 2 commits February 21, 2026 10:50
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@MakisH
Copy link
Member

MakisH commented Feb 22, 2026

Hi there! Thanks for the contribution!

Before I look closer, note that this PR touches many symlinks without reason:

clean-tutorial.sh -> 'cd "$(cd "$(dirname "$0")" && pwd)"'$'\n''../tools/clean-tutorial-base.sh'

which also breaks them. Please restore those.

Could you please explain a bit the approach you use? Shellcheck does not complain, but it is also rather cryptic. I know there are a few different ways to achieve this.

I also wonder if there is a better way to encapsulate this in some central file, and not touch every cleaning script.

Is this something you have previous experience with or seen it used somewhere else, or is it mainly a suggestion by Cursor? Both are valid, but it is important to know how to review it.

@PranjalManhgaye
Copy link
Contributor Author

sure " I also wonder if there is a better way to encapsulate this in some central file, and not touch every cleaning script" i will work on that , thanks for your suggestion

@PranjalManhgaye
Copy link
Contributor Author

PranjalManhgaye commented Feb 23, 2026

thanks @MakisH for the quick feedback, much appreciated ,
You’re right about the symlinks. That change was unintentional, and I agree it modifies more files than necessary and breaks the symlink setup. I’ll restore them and adjust the fix so only the actual targets (or a small central entry point) are touched, I’m familiar with this general $0/dirname pattern from previous shell work,
The intent was simply to make the scripts independent of the working directory by resolving their own location. I used the common dirname "$0" pattern for that, but I agree it’s not the most readable approach. Refactoring this into a small shared helper makes more sense and keeps the diff minimal.
On centralization => in hindsight, that would indeed be the cleaner design. Moving this logic into a shared helper (for example under tools/) and sourcing it from clean-all.sh / clean-tutorial.sh would avoid touching each individual script and keep the diff much smaller. I’ll refactor the PR in that direction so the changes stay focused and are easier to review.
I’ll update the PR to:

  1. Revert the symlink changes.
  2. Move the path-resolution logic into a central helper.
  3. Limit the changes to only the scripts that truly need it.
    Let me know if you have a preferred location or pattern for the helper, and I’ll align with that, thanks

@MakisH MakisH added the GSoC Contributed in the context of the Google Summer of Code label Feb 23, 2026
@MakisH MakisH requested a review from Copilot February 23, 2026 18:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #667 by implementing path resolution logic in cleaning scripts to make them callable from any directory, not just their local directories. The fix enables scripts to determine their own location and change to that directory before sourcing relative path dependencies.

Changes:

  • Added script directory resolution to clean-all.sh to ensure it operates from the repository root regardless of where it's called from
  • Added tutorial directory resolution to tools/clean-tutorial-base.sh to enable clean-tutorial scripts to work when called from different directories
  • Scripts now use the pattern SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" followed by cd "$SCRIPT_DIR" before sourcing relative paths

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
clean-all.sh Added path resolution logic to ensure the script runs from the repository root, making it callable from any directory
tools/clean-tutorial-base.sh Added path resolution logic to determine the tutorial directory and change to it before sourcing relative dependencies, enabling clean-tutorial scripts (that are symlinks to this base) to work from any location

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MakisH
Copy link
Member

MakisH commented Feb 23, 2026

I am not sure that I understand the hack enough, but it works, and it is isolated.

Don't forget adding a changelog entry as well (see changelog-entries/), as this is user-facing.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PranjalManhgaye
Copy link
Contributor Author

added changelog-entries/716.md
thanks for your review @MakisH
please let me know if there’s anything else , that i should do in this pr ,

@MakisH MakisH changed the title Fix clean scripts Make clean-tutorial.sh executable from any directory Feb 23, 2026
Copy link
Member

@MakisH MakisH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MakisH MakisH merged commit 0c91000 into precice:develop Feb 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSoC Contributed in the context of the Google Summer of Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants