add parameter expansion, arithmetic, set -e/-x/pipefail, trap, eval, exec

- ${#v}, ${v#p} ${v##p} ${v%p} ${v%%p}, ${v/p/r} ${v//p/r} ${v/#p/r}
  ${v/%p/r}, ${v:off:len}, ${v-w} ${v:=w} ${v:+w} ${v:?msg}; nested ${}
- arithmetic expansion $((...)) with the C operators, ** and assignments
- set -e, set -x, set -o pipefail (also as gosh options, passed on to
  subshells); set shows variables, set -o the options
- trap for EXIT and signals; scripts with an EXIT trap run it on
  SIGINT/SIGTERM/SIGHUP too
- eval, exec (also exec > file without a command), $!, wait pid

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Florian WaltherandClaude Opus 5.5 committed 2026-10-04 21:15:24 +02:00
1 parent f66cf538c0
commit 1f507f6562
20 files changed
+2408 -93

No files matched your search

+6 -7
View File
@@ -631,12 +631,11 @@ func TestExecInput_ExportEnvVar(t *testing.T) {
}
func TestExecInput_SetNoArgs(t *testing.T) {
err := execInput("set")
if err == nil {
t.Error("expected error for set with no args, got nil")
}
if !strings.Contains(err.Error(), "usage: set VAR=value") {
t.Errorf("expected usage error, got: %v", err)
// set without arguments shows the variables, quoted for the shell
t.Setenv("GOSH_SHOWN", "a b")
got := runIn(t, "set > out")
if !strings.Contains(got, "GOSH_SHOWN='a b'\n") {
t.Errorf("set: GOSH_SHOWN missing in %q", got)
}
}
@@ -1366,7 +1365,7 @@ func TestRun_Options(t *testing.T) {
{[]string{"-c", "false"}, 1},
{[]string{"-l", "--noprofile", "-c", "sh -c 'exit 5'"}, 5},
{[]string{"-c"}, 2},
{[]string{"-x"}, 2},
{[]string{"-z"}, 2},
{[]string{"/gosh/no/such/script"}, 127},
}
for _, tc := range tests {