Following on from my perl_config configuration file parser, I set about writing a similar tool using ksh. I wanted to parse a configuration file of variable assignments, and then use eval to assign these internally within the script, making them available for use inside the script. I could have sourced the assignments in using the "dot" operator but I decided against this - a hapless (or malicious) user could easily insert commands into the sourced file causing all manner of problems. I just wanted plain old assignments to be read - so sh_config was born.
sh_config will parse configuration files of the following general form....
# This is a comment which will be ignored # So is this # Note - whitespace doesn't matter in assignments # but a variable name cannot contain whitespace (the value can) backup_dir = /some/directory another_variable = some assignment # inline comment some_var=some_val
Within the download tarball, you'll find two files. The sh_config script itself, and a sample configuration file, sh_config.conf. Read the notes at the top of the script and the comments throughout for further information.