Files
bare-operating-system/packages/bare-os-booter/lib/shell/shell-token.js
T
2026-08-18 18:11:28 -04:00

23 lines
549 B
JavaScript

/**
* Token wrapper around {@link ./shell-lex.js} used by aliases, parse, and exec.
*/
import { lexShellLine } from './shell-lex.js'
/**
* @typedef {{ q: 'u' | 's' | 'd', t: string }} ShellWordPart
*/
/**
* @typedef {{ type: 'word', value: string, parts: ShellWordPart[] } | { type: 'op', value: string }} Token
*/
/** @param {Token} t */
export function shellWordText(t) {
return t && t.type === 'word' ? t.value : ''
}
/** @param {string} line */
export function tokenize(line) {
return /** @type {Token[]} */ (lexShellLine(line))
}