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

+5 -1
View File
@@ -58,7 +58,8 @@ func builtinRead(args []string, stdin *os.File) error {
if prompt != "" && terminal {
fmt.Fprint(stdio(2), prompt)
}
line, literal, eof, err := readInputLine(stdin, raw, interactiveShell && terminal)
// Ctrl+C or a trapped signal ends a read from the terminal
line, literal, eof, err := readInputLine(stdin, raw, terminal && (interactiveShell || len(trapChans) > 0))
if err != nil {
return err
}
@@ -160,6 +161,9 @@ func interruptibleByteReader(f *os.File, intr chan os.Signal) func() (byte, erro
return 0, statusError(128 + int(syscall.SIGINT))
default:
}
if hasPendingSignal() {
return 0, statusError(128 + int(syscall.SIGINT))
}
n, err := unix.Poll(fds, 100)
if err != nil && !errors.Is(err, unix.EINTR) {
return 0, err