Skip to content

knrafto/bash-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bash-config

This package allows Bash configuration files to be parsed and interpreted from Haskell, without executing any commands. Many shell scripts use these as configuration files, which are intended to be sourced for shell variable assignments.

This library fully parses Bash scripts, but can only interpret a limited subset of Bash. No commands are actually executed. Since this in theory could limit the ability to interpret a configuration file, the interpreter only returns variables it is sure are correct; all other variables are unknown. In practice, however, configuration scripts are simple enough and pure enough for the library to interpret completely.

Features

Implemented features are executed faithfully. Unimplemented features are executed in a safe manner, removing variables that could change. Unsafe features cause the interpreter to fail.

Implemented

  • Parameter assignment and compound assignment
  • Arrays
  • Most parameter expansions
  • Brace expansions
  • Groups, subshells, pipelines, &&, and ||
  • Conditional commands ([[ .. ]], test, and [ .. ])
  • true and false
  • if statements
  • Function definitions
  • Function execution

Partially implemented

  • Assignment builtins alias, declare, export, local, readonly, and typeset. Implementations are currently unsafe.

Unimplemented

  • Special and positional parameters
  • External commands
  • Redirections
  • Builtins cd, pwd, eval, break, continue, etc.
  • Tilde expansion
  • Filename expansion
  • Command, process, and arithmetic substitution
  • Arithmetic commands
  • Looping constructs
  • Case commands

Unsafe

  • Builtins exit, return, source, ., etc.

About

Safely interpret Bash scripts as configuration files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published