// A `( … )` group: a subshell's span in the source and the group it sits in. import { Schema } from "effect"; /** * One `( … )` group of a script: a subshell, so a `cd` inside it changes * nothing after its `)`. * * @remarks * `start` is the offset of its `(` and `end` the offset past its `)`, or the * end of the source when it has none (`closed` is then `false`, and bash * rejects the script). `parent` is the index in `ShellScript.groups` of the * group it sits in, `None` at the top level, so the groups form a tree. * Groups are numbered by their `(`, in source order. A segment names its * innermost group in `ShellSegment.group`. * * Only a subshell is a group: the parentheses of `[[ ( … ) ]]`, a `case` * pattern's `)` and a function definition's `NAME()` open none, and * `{ … }` runs in the current shell. Groups inside a command substitution * belong to the script its body parses to. * * @public */ export class ShellGroup extends Schema.Class("ShellGroup")({ start: Schema.Number, end: Schema.Number, parent: Schema.Option(Schema.Number), closed: Schema.Boolean, }) {}