In this case, sdir is a base path I define elsewhere, and sfile is another prefix. Those are hard coded into the top of the script, so those will always be correct.
What I'm trying to do here is first set the first eight variables to the proper default values. That's the first area I'm thinking there might be a way to optimize. Is there anyway to set both variables at once for example I know in PHP I could do $title=$d_title="value";$title=$d_title="value"; Is there any way to consolidate that section? (The variables prefixed with 'd_'d_ will not change, but the same variable without the 'd_'d_ may be changed.)
Then the rest of the snippet should do the following:
If the second argument is NOT "config"
-Look in the file to see if the a line with the format ${sfile}_variablename="*" exists.
--If it does, use sed to replace the contents of the quotes with the new variable
--If it does not, append the line in its entirety
If the second argument IS "config"
-If a line exists that contains ${sfile}_variablename, read in what's between the quotes and assign it to the variablename
-If not, set the variablename to the default value
If the second argument is NOT "config"
- Look in the file to see if the a line with the format
${sfile}_variablename="*"exists.- If it does, use sed to replace the contents of the quotes with the new variable
- If it does not, append the line in its entirety
- Look in the file to see if the a line with the format
If the second argument IS "config"
- If a line exists that contains
${sfile}_variablename, read in what's between the quotes and assign it to the variablename - If not, set the variablename to the default value
- If a line exists that contains
Below is how I was achieving that. Is there any way to do this in a more simplified or compact manner?
In this case, sdir is a base path I define elsewhere, and sfile is another prefix. Those are hard-coded into the top of the script, so those will always be correct.