I found some questions about processing an ini/bash file.
For example: Best/easiest way to parse configuration parameters in Sh/Bash and php
However they doesn't take in account other kind of assignments like:
arrays:
stuff=( "foo" "bar" "donald duck" "mickey mouse" )
variables calling another variable:
foobar = "bartender"
foo = "$foobar give me a beer!"
possible other things I'm not figuring them atm
Instead of parsing the variables in php side i was thinking instead of using a shell script processing an input config.sh file and prepare a vars.php files already written in php language.
So an array like the one above will be converted in $stuff = array ("foo", "bar", "donald duck", "mickey mouse" )
and the other variables like $foo = "bartender give me a beer!"
But how is possible export via bash the variables definied into a shell script in an efficient way ? Has bash something like php $GLOBALS
in order to cycle throught the definied vars ?
I think also an intelligent bash script "sh variables to json" could work, so that the json could be parsed in php after :)
To be more clear, I'm writing a set of scripts that are based on a config.sh file. But, i have a slight amount of php scripts also that need the same configuration, that's why I tought would have been easier prepend all my php script with a parse of the config.sh file so I can use the same vars I have in bash also in php.
While some parser of ini/bash definition exists they are mere literal parser without taking in account variables inside other variables and arrays.