Runs a shell script and returns set variables in it.
Go to file
Zane C. B-H c7f6661521 add munging support via -m and bump to 0.4.0 2023-07-25 11:15:43 -05:00
bin finalize the last bit 2022-11-08 08:50:05 -06:00
lib/Shell/Var add munging support via -m and bump to 0.4.0 2023-07-25 11:15:43 -05:00
src_bin add munging support via -m and bump to 0.4.0 2023-07-25 11:15:43 -05:00
t add initial files 2022-10-02 22:38:40 -05:00
.gitignore now the changes and ready for release 2022-11-08 08:58:51 -06:00
Changes add munging support via -m and bump to 0.4.0 2023-07-25 11:15:43 -05:00
MANIFEST finalize the last bit 2022-11-08 08:50:05 -06:00
Makefile.PL flatten data for shell output and bump to 0.3.1 for release 2023-07-07 15:53:16 -05:00
README.md add install info 2022-11-08 09:13:13 -06:00
ignore.txt add initial files 2022-10-02 22:38:40 -05:00

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