packPNG v1.8c - smart console-detection prompt
v1.8c - smart console detection: only prompt on a fresh console
Third bugfix on the v1.8 line. v1.8a fixed the double-click console-close
problem by always printing "Press to quit" on every help / error
exit. Real-world feedback: that was correct for double-click but noisy
in every other context -- running from cmd.exe, PowerShell, Windows
Terminal, SSH, or a .bat would also show the prompt, even though the
console is shared with a parent shell that survives our exit.
The fix
Detect whether the console is fresh (only packPNG attached, will
close on our exit) before showing the prompt. On Windows, this is
GetConsoleProcessList(buf, 2) returning 1. On Linux, terminal
emulators outlive us in every realistic case, so it always returns
false -- the prompt was always noise on Linux and v1.8c retires it
there too.
| Invocation | console_is_fresh | prompt? |
|---|---|---|
Windows: double-click .exe directly |
yes (1 proc) | yes |
| Windows: from cmd.exe / PowerShell / Windows Terminal | no (2+ procs) | no |
Windows: from a .bat file |
no (cmd is parent) | no |
| Windows: from SSH | no (sshd shell is ancestor) | no |
| Linux: any context | no (always) | no |
-np and -module continue to bypass the prompt unconditionally for
scripted / machine invocations, exactly as before.
Verified
On Windows 11 (DESKTOP-6R6L470, build 26200, PowerShell 5.1.26100) via
SSH:
Test 1 no-args from cmd no prompt PASS
Test 2 -mZ error from cmd no prompt PASS
Test 3 -np regression no prompt PASS
The fresh-console branch is verified manually by double-clicking the
.exe in Explorer and confirming "Press <enter> to quit" still
appears -- this is the path the bat selftest cannot reach (invoking a
.bat already establishes cmd.exe as parent, defeating the fresh
detection).
What didn't change
- Wire format unchanged:
.ppgfiles written by v1.8 / v1.8a /
v1.8b decode under v1.8c and vice versa. BothTCIP(PNG/APNG) and
TCIJ(JNG) magics are intact. - Compression algorithm unchanged: the tovyCIP backend
(kanzi RLT+BWT+SRT+ZRLT/FPAQ+zstd-19 --long=27) is byte-exact
identical to every prior release on the v1.8 line. - All v1.8a/b behaviours preserved apart from the prompt narrowing:
the wait_and_return helper, exit-code handling for invalid magic
(v1.8b), JNG support (v1.8), are all untouched. - Manifest
assemblyIdentity@versionbumped1.8.0.2->1.8.0.3.
Binaries
packPNG-linux-x86_64-v1.8c- Linux x86-64.packPNG-windows-x86_64-full-v1.8c.exe- Windows x86-64, statically
linked, mingw-w64 cross-compiled, UTF-8 active-code-page manifest.test-v1.8c.bat- drop-next-to-the-exe selftest harness, 14 tests
(regression set + flipped prompt expectations from v1.8a/b).
🤖 Generated with Claude Code