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:
1 parent
f66cf538c0
commit
1f507f6562
20 files changed
+2408
-93
No files matched your search
@@ -79,16 +79,14 @@ func subshellCommand(script string, params []string) (*exec.Cmd, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args := append([]string{"-c", functionDefs() + script, scriptName}, params...)
|
||||
args := append(optionFlags(), "-c", functionDefs()+script, scriptName)
|
||||
args = append(args, params...)
|
||||
return exec.Command(path, args...), nil
|
||||
}
|
||||
|
||||
// commandSubst runs command in a subshell and returns its output without
|
||||
// trailing newlines. stdin and stderr are those of the shell.
|
||||
func commandSubst(command string) (string, error) {
|
||||
if strings.HasPrefix(command, "(") {
|
||||
return "", errors.New("arithmetic expansion $((...)) is not supported")
|
||||
}
|
||||
var out bytes.Buffer
|
||||
cmd, err := subshellCommand(command, positional)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user