|
From: | Clark WANG |
Subject: | Re: [Help-bash] Sourcing only valid variables from a script configuration file |
Date: | Mon, 2 Jul 2012 16:48:38 +0800 |
Hello everyone
I am trying to do something that bash doesn't seem to be very good at. I'll admit right now that the best advice for myself would be to re-write my script in python or perl. However, I really wanted to do this in bash for educational purposes. Thus, I have created a monster.
I have a script which reads a configuration file, which is simply made up of comments and variable assignments.
'source' is the obvious correct command to bring this configuration file into the script. However, I want input validation and other protections against commands and other non-expected data from being in the configuration file.
In this configuration file, the variables are known and expected. If an expected variable is missing or invalid, we exit with an error. If addition non-variable or comment data is in the configuration file, we should also exit with an error.
I will probably end up writing a function to validate the stat() on the file, grep for anything invalid, make sure there are no command substitution or similar nonsense within the valid variables, and the like.
Does anyone have any helpful advice for me on this subject beyond what I already know here?
[Prev in Thread] | Current Thread | [Next in Thread] |