compile.sh: guard the cd before rm -rf *, which can delete the source tree - #59
Open
Sohex wants to merge 1 commit into
Open
compile.sh: guard the cd before rm -rf *, which can delete the source tree#59Sohex wants to merge 1 commit into
rm -rf *, which can delete the source tree#59Sohex wants to merge 1 commit into
Conversation
…ce tree
compile.sh does
cd plasim/bld/
rm -rf *
with no `set -e` and no guard on the `cd`. `plasim/bld` is a build directory and
is not tracked, so it does not exist in a fresh clone. The `cd` then fails,
execution continues, and the `rm -rf *` runs in the PACKAGE ROOT instead.
That deletes the source tree. I hit it building from a checkout rather than an
installed wheel: 1437 files removed, including plasim/src, the sample .sra
files and the documentation. Recoverable from git, but only because it was a git
checkout -- run against an unpacked tarball or a working copy with local edits
it is unrecoverable.
An installed wheel usually has plasim/bld already present, which is why this
does not show up in normal use.
The fix creates the directory and refuses to continue if it still cannot enter
it. plasim/bin is created at the same time because the link step writes
../bin/newsnow.x and ../bin/buildice.x and fails the same way if it is absent on
a fresh tree.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sohex
force-pushed
the
fix/compile-rm-rf-guard
branch
from
August 19, 2026 02:42
c96fc9d to
62bb475
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
compile.shdoeswith no
set -eand no guard on thecd.plasim/bldis a build directory and is not tracked, so it does not exist in a fresh clone. Thecdfails, execution continues, and therm -rf *runs in the package root instead.I hit this building from a git checkout rather than an installed wheel: 1437 files deleted, including
plasim/src, the sample.srafiles and the documentation. Recoverable in my case only because it was a git checkout -- against an unpacked tarball, or a working copy with local edits, it is not.An installed wheel normally has
plasim/bldpresent already, which is why this does not bite in ordinary use.The fix creates the directory and refuses to continue if it still cannot enter it.
plasim/binis created alongside because the link step writes../bin/newsnow.xand../bin/buildice.xand fails the same way on a fresh tree.