Metadata-Version: 2.2
Name: sh-expand
Version: 0.2.1
Summary: A library for expanding shell ASTs
Author-email: Michael Greenberg <michael@greenberg.science>, Konstantinos Kallas <konstantinos.kallas@hotmail.com>
License: MIT License
        
        Copyright (c) 2023 The PaSh Authors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/binpash/sh-expand
Project-URL: Bug Tracker, https://github.com/binpash/sh-expand/issues
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: System :: System Shells
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: shasta
Requires-Dist: pexpect
Provides-Extra: dev
Requires-Dist: libbash; extra == "dev"
Requires-Dist: libdash; extra == "dev"
Dynamic: requires-python

# sh-expand

A python library for expanding shell ASTs that can be used to construct sound analyses for shell scripts (after having expanded the AST).

## Design

There are two implementations of shell expansion:
1. `expand.py` does an in-python expansion of simple & safe AST nodes. It doesn't support bashisms.
2. `bash_expand.py` expands by conservatively echoing safe commands to a bash process containing the current shell state.

Both, when called via `expand_command`, recurse down into the words of a shasta AST node to
expand, leave the word as is, or raise an ExpansionError. Examples:
- Process substitutions are unsafe.
- Simple variable substitutions are safe.
- Assignments are considered unsafe, since in Pash they indicate an unparallelizable region.

`expand.py` interprets the ArgChars libdash parses (ex: for variable and process substitutions)
to check and expand words.

Libbash does not parse ArgChars, so `bash_expand.py` instead conservatively checks
for the presence of potentially expandable or unsafe literal characters (see `should_expand_var`)
before expanding.

Not having proper ArgChar parsing causes false positive unsafe errors,
so `expand.py` should eventually be extended to support bash-only AST nodes,
and libbash and shasta extended to parse ArgChars.
