[Bug]: -Q before --script stays in command-line-args-left and fails with "Unknown option ‘-Q’"
Bug summary
If -Q comes before --script, Neomacs leaves -Q in command-line-args-left when it runs the script. After the script finishes, it fails with Unknown option ‘-Q’ and exit status 255. GNU Emacs 31.1 consumes -Q and runs the same command cleanly.
This breaks Nix builds that run emacs -Q --batch --script for every package. nix-doom-emacs-unstraightened is one of them: it reads a package's dependencies this way ($emacs -Q --batch --script $printDeps $src $name), so building Doom on Neomacs fails on its first package.
Steps to reproduce
echo '(princ (format "%S" command-line-args-left))' > /tmp/t.el
neomacs -Q --batch --script /tmp/t.el a b; echo " rc=$?"
neomacs --batch -Q --script /tmp/t.el a b; echo " rc=$?"
neomacs --script /tmp/t.el a b; echo " rc=$?"
Output:
Unknown option ‘-Q’
("-Q" "a" "b") rc=255
Unknown option ‘-Q’
("-Q" "a" "b") rc=255
("a" "b") rc=0
neomacs -Q --batch --eval '(princ emacs-version)' works, so the problem shows only when --script is present.
Expected behavior
As in GNU Emacs: -Q is consumed, the script sees ("a" "b"), and the exit status is 0.
Neomacs --version output
Neomacs 0.0.20
Git commit: unknown
Source date: unknown
(This is packages.x86_64-linux.default from the flake at tag v0.0.20, substituted from eval-exec.cachix.org.)
Platform
Guix System x86_64 (Nix package manager), Hyprland.
Install source
Nix flake, github:eval-exec/neomacs/v0.0.20.
Extra context
I have not tested current main. crates/neomacs/src/args.rs (the argument sorting) looks unchanged since v0.0.20, so the bug may still be there. Our current workaround is a wrapper that drops -Q whenever --script is present.