Skip to content

compile.sh: guard the cd before rm -rf *, which can delete the source tree - #59

Open
Sohex wants to merge 1 commit into
alphaparrot:masterfrom
Sohex:fix/compile-rm-rf-guard
Open

compile.sh: guard the cd before rm -rf *, which can delete the source tree#59
Sohex wants to merge 1 commit into
alphaparrot:masterfrom
Sohex:fix/compile-rm-rf-guard

Conversation

@Sohex

@Sohex Sohex commented Aug 19, 2026

Copy link
Copy Markdown

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 fails, execution continues, and the rm -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 .sra files 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/bld present 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/bin is created alongside because the link step writes ../bin/newsnow.x and ../bin/buildice.x and fails the same way on a fresh tree.

…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
Sohex force-pushed the fix/compile-rm-rf-guard branch from c96fc9d to 62bb475 Compare August 19, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant