Runs a shell script and returns set variables in it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zane C. B-H b3dcc0eca2
add install info
4 months ago
bin finalize the last bit 4 months ago
lib/Shell/Var now the changes and ready for release 4 months ago
src_bin now the changes and ready for release 4 months ago
t add initial files 6 months ago
.gitignore now the changes and ready for release 4 months ago
Changes add install info 4 months ago
MANIFEST finalize the last bit 4 months ago
Makefile.PL now the changes and ready for release 4 months ago
README.md add install info 4 months ago
ignore.txt add initial files 6 months ago

README.md

Shell-Var-Reader

Lets say '/usr/local/etc/someconfig.conf' which is basically a shell config and read via include in a sh or bash script, this can be used for getting a hash ref conttaining them.

Similarly on systems like FreeBSD, this is also useful for reading '/etc/rc.conf'.

As it currently stands, it does not understand bash arrays.

use Shell::Var::Reader;
use Data::Dumper;

my $found_vars=Shell::Var::Reader->read_in('/usr/local/etc/someconfig.conf');

print Dumper($found_vars);

bin/shell_var_reader

This script allows for easy reading of a shells script/config and then outputing it in a desired format.

-r <file>     File to read/run
-o <format>   Output formats
              Default: json
              Formats: json,yaml,toml,dumper(Data::Dumper)
-p            Pretty print
-s            Sort

-h/--help     Help
-v/--version  Version

Install

FreeBSD

pkg install p5-YAML p5-JSON p5-TOML p5-Data-Dumper \
    p5-String-ShellQuote p5-File-Slurp p5-App-cpanm
cpanm Shell::Var::Reader

Debian

apt-get install libfile-slurp-perl libjson-perl libyaml-perl \
        libtoml-perl libstring-shellquote-perl cpanminus
cpanm Shell::Var::Reader

Source

perl Makefile.PL
make
make test
make install