FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix error handling in the fetch-Lua target by g4b0 · Pull Request #1657 · NetHack/NetHack · GitHub

Fix error handling in the fetch-Lua target - #1657

Open
g4b0 wants to merge 1 commit into
NetHack:NetHack-5.0from
g4b0:fix/fetch-lua-error-handling
Open

Fix error handling in the fetch-Lua target#1657
g4b0 wants to merge 1 commit into
NetHack:NetHack-5.0from
g4b0:fix/fetch-lua-error-handling

Conversation

g4b0 commented Aug 15, 2026

Copy link
Copy Markdown

Three small defects in the fetch-Lua target in sys/unix/Makefile.top. I went looking for the CHKSUMS.tmp leftover and found the other two next to it.

1. The "no checksum known" branch could never run

CHKSUMSTMP=../submodules/CHKSUMS.tmp
fgrep $luafile < $CHKSUMS > $CHKSUMSTMP
if [ -z $CHKSUMSTMP ]; then

-z tests the filename string, which is never empty, so the branch was dead. A tarball with no entry in submodules/CHKSUMS fell through to the else branch and was "verified" against an empty checklist.

Building with a Lua version that has no checksum entry, before and after:

# before
Searching for known checksum
Checksum found
Checking integrity of lua-5.4.4.tar.gz with /usr/bin/shasum -a 256
shasum: ../submodules/CHKSUMS.tmp: no properly formatted SHA checksum lines found
Integrity check FAILED - STOPPING

# after
Searching for known checksum
Cannot check lua-5.4.4.tar.gz - no checksum known
Rerun with 'NOCHKSUM=1' to skip this check

It fails closed either way, so this is not a security issue, but "Integrity check FAILED" points at a corrupted or tampered download when the real cause is a missing entry.

2. Exhausting every download source exited 0

echo "Unable to find a valid source - STOPPING" \
exit 1; \

The line continuation makes exit 1 an argument to echo, so the subshell exits 0 and make reports success. The build then fails later with "Please do 'make fetch-lua'", which is the message you just tried to act on.

# before
$ make fetch-lua LUA_VERSION=9.9.9; echo "exit=$?"
curl: (22) The requested URL returned error: 404
Unable to find a valid source - STOPPING exit 1
exit=0

# after
$ make fetch-lua LUA_VERSION=9.9.9; echo "exit=$?"
curl: (22) The requested URL returned error: 404
Unable to find a valid source - STOPPING
make: *** [Makefile:2534: fetch-Lua] Error 1
exit=2

3. CHKSUMS.tmp was never removed

It is now deleted on both exits from the checksum block. Not on the integrity-failure path, where the build has stopped hard and the file is more useful kept than removed.

Testing

Ubuntu 24.04, gcc, sys/unix/hints/linux.500, tty.

  • make fetch-lua then make all and make install: unchanged, game builds and runs, CHKSUMS.tmp no longer left behind.
  • LUA_VERSION=9.9.9 (no such tarball anywhere): exit 0 before, exit 2 after.
  • LUA_VERSION=5.4.4 (downloads fine, absent from CHKSUMS): misleading integrity failure before, accurate message after.
  • I have not tested on macOS or BSD, and have not exercised the NOCHKSUM=1 path.

No doc/fixes5-0-1.txt entry, since recent contributor PRs leave that to you. Happy to add one if you would rather have it.

🤖 Generated with Claude Code

Three defects in sys/unix/Makefile.top:

The "no checksum known" test read [ -z $CHKSUMSTMP ], which tests the
filename string rather than the file, so it never fired.  A tarball
with no entry in submodules/CHKSUMS reported "Checksum found" and then
failed with "Integrity check FAILED - STOPPING", which suggests a
corrupted or tampered download rather than a missing checksum.  It now
tests [ ! -s $CHKSUMSTMP ] and reports the real reason.

A missing semicolon left "exit 1" as an argument to echo on the final
failure path, so exhausting every download source exited 0 and make
reported success.

CHKSUMS.tmp was never removed; it is now deleted on both exits.
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL