add command substitution $(...)
- $(command) is replaced by the output of command, which runs in a subshell (gosh -c), so cd/set in it do not change the shell - trailing newlines are removed; unquoted the output is split into words at blanks and newlines, "$(...)" stays one word; wildcards in the output are not expanded - nested substitutions, quotes and operators inside are handled; the list, alias and brace scanners skip $(...) as a whole - a command that consists only of a substitution has its exit status, Ctrl+C in a substitution aborts the command - $((...)) is reported as not supported Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
041406a340
commit
e49fe6fe11
7 files changed
+311
-3
No files matched your search
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -892,6 +893,11 @@ func TestMain(m *testing.M) {
|
||||
// Never read the system's startup files; tests that read the user's
|
||||
// files set $HOME themselves
|
||||
sysConfDir = filepath.Join(dir, "etc")
|
||||
// Command substitution runs gosh, not the test binary
|
||||
subshellPath = filepath.Join(dir, "gosh")
|
||||
if out, err := exec.Command("go", "build", "-o", subshellPath, ".").CombinedOutput(); err != nil {
|
||||
panic(fmt.Sprintf("building gosh: %v\n%s", err, out))
|
||||
}
|
||||
code := m.Run()
|
||||
os.RemoveAll(dir)
|
||||
os.Exit(code)
|
||||
|
||||
Reference in new issue
Block a user