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
@@ -96,6 +96,16 @@ func expandAliasesIn(line string, active map[string]bool) string {
|
||||
}
|
||||
}
|
||||
|
||||
if quote != '\'' && !escaped && isSubstStart(line, i) {
|
||||
// $(...) is copied as it is; the subshell does not expand
|
||||
// aliases
|
||||
if end := substEnd(line, i); end >= 0 {
|
||||
out.WriteString(line[i : end+1])
|
||||
i = end
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
out.WriteByte(ch)
|
||||
switch {
|
||||
case escaped:
|
||||
|
||||
Reference in new issue
Block a user