Description
Split one restricted shell parameter default expansion ${NAME-word} or ${NAME:-word}, preserving empty-vs-unset semantics; excludes nested expansions, escapes and execution.
Shell token meaning depends on quote context, escape syntax, parameter expansion, and the particular shell. A literal split or escape decoder can inspect text without evaluating it. Recognizing a token does not execute a command or reproduce every rule of a complete shell parser.
Split one restricted shell parameter default expansion ${NAME-word} or ${NAME:-word}, preserving empty-vs-unset semantics; excludes nested expansions, escapes and execution.
When to use this tool
Use Parsing: Shell Parameter Simple Default Split when you need to inspect the supported literal shell-related token or escape without evaluating it.
How to use the tool and how it works
- Enter token. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read result. Expand result to inspect the returned fields.
Accept a simple parameter expansion with an ASCII variable name, operator - or :-, and a fallback without braces or line breaks. Return parameter, operator, literal fallback, and emptyUsesFallback=true only for :- inside result.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| token | Complete literal token in the grammar stated above. | Required. Text. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| result | Object containing the calculated result members described below. | Required. Object. |
| result.parameter | Parameter | Calculated result member: string. |
| result.operator | Operator | Calculated result member: string. |
| result.fallback | Fallback | Calculated result member: string. |
| result.emptyUsesFallback | Empty Uses Fallback | Calculated result member: boolean. |
{
"input": {
"token": "${NAME:-default}"
},
"output": {
"result": {
"parameter": "NAME",
"operator": ":-",
"fallback": "default",
"emptyUsesFallback": true
}
}
} Limitations and assumptions
- The operator is labeled rather than evaluated against an environment. Nested expansion, quoting semantics, command substitution, and a complete shell grammar are unsupported; no shell code is run.
- Outputs are nested inside result. Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
Alternative or Complementary methods
Use a shell-aware lexer or parser for quote context, concatenated words, nested expansions, and complete command syntax. Preserve untrusted text as data when its role is inspection.
References
Similar or alternative tools
- Shell Single Quoted Token Boundary
Extract literal text after a shell single-quote opener and report whether the first closing quote ends the token.
- Parsing: Dotenv Single Assignment Split
Split a restricted dotenv assignment at its first equals sign, retaining raw value and optional export prefix without evaluating quoting, interpolation or comments.