NAME

Proc::ShellSubset::Large - parse as much of POSIX sh as dash and bash run alike (EXPERIMENTAL)

SYNOPSIS

use Proc::ShellSubset::Large;
my $t = Proc::ShellSubset::Large::parse('f() { local x=$1; echo "${x%.c}"; }; for a; do f "$a"; done');

DESCRIPTION

parse($string, %options) returns a tree or an error hash, as "parse" in Proc::ShellSubset does. It first asks Proc::ShellSubset (with if, while, for, case, read, assign and param_ops on); only if that rejects the string does it parse it again by a wider grammar. It adds, among others: function definitions, local, export, readonly, unset, set, shift, eval, ., trap, wait, umask, command, getopts, return, exec with redirections only, positional parameters and all POSIX parameter forms, here-documents, command names from expansions, assignments in arithmetic, redirections without a command, and backslash-newline anywhere.

Where dash and bash differ, the subset takes the plainly logical behaviour where there is one, and rejects the construct otherwise, so that the caller can hand the string to /bin/sh (rule E, with the list of choices in doc/large-subset/large-subset-logical.md). A construct outside the subset that shows up only at run time makes Proc::ShellSpawn stop that shell with status 248 (rule A4); differences that show up only at run time follow dash (rule A5).

Options: those of Proc::ShellSubset, except brace (brace expansion is bash only).

The specification, with the tree additions, is doc/large-subset/large-subset-spec.md; the corpus measurements are in doc/large-subset/large-subset-state.md.

SEE ALSO

Proc::ShellSubset, Proc::ShellSpawn, doc/large-subset/README.md.