Add RunProcess, a safer alternative to Exec - #6536
Open
fingolfin wants to merge 1 commit into
Open
Conversation
fingolfin
marked this pull request as ready for review
August 29, 2026 13:14
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6536 +/- ##
==========================================
+ Coverage 78.98% 78.99% +0.01%
==========================================
Files 684 684
Lines 294205 294271 +66
Branches 8647 8670 +23
==========================================
+ Hits 232369 232466 +97
+ Misses 60028 59986 -42
- Partials 1808 1819 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`Exec` hands its concatenated arguments to a shell. That makes it hard to pass arguments containing spaces or quotes, ties the behaviour to whichever shell is installed, discards the exit code, and wires the child process to the user's terminal. `RunProcess` takes the program and its arguments as separate strings and runs it directly, so nothing needs quoting and no shell is involved. It returns a record holding the exit code and, by default, the captured output. Anything beyond the command line is passed in an optional trailing options record with the keys `directory`, `input` and `output`; unknown keys are rejected, so that `error` can be added once GAP is able to capture the standard error stream of a child process (see #4657). The price is that shell features such as redirections and wildcard expansion are no longer available, so `Exec` stays. Convert the callers in `helpview.gi` and `streams.gi`. The terminal browsers keep the user's terminal explicitly, as they are interactive. Co-authored-by: Claude <noreply@anthropic.com>
fingolfin
force-pushed
the
mh/RunProcess
branch
from
August 29, 2026 14:36
6d1efcd to
3eb8de7
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.
Grew out of #5103, and hence closes #5103.
Exechands its concatenated arguments to a shell. That makes it hard to pass arguments containing spaces or quotes, ties the behaviour to whichever shell happens to be installed, discards the exit code, and wires the child process to the user's terminal.RunProcesstakes the program and its arguments as separate strings and runs it directly:For example:
The price is that shell features such as redirections and wildcard expansion are gone, so
Execstays; its documentation now points here for new code.What changed since #5103
The draft let the working directory and the streams appear as positional arguments in any order. Following the discussion there (@ChrisJefferson, @wilfwilson), everything beyond the command line now goes into an optional trailing options record with the keys
directory,inputandoutput:Unknown keys are rejected rather than ignored. That is the point of the record: GAP currently cannot capture a child process's standard error at all (#4657), and this leaves room to add an
errorkey later without breaking any caller — and without older GAP versions silently dropping it.The name is the other thing #5103 stalled on.
RunProcesssits next to the existingProcessoperation, reads as a verb, and matches Mathematica'sRunProcessand Python'ssubprocess.run.Arguments must be strings or integers; anything else is an error. Deliberately not
String-ing arbitrary objects, as that would close off future extensions.Co-authored-by: Claude Opus 5 noreply@anthropic.com