Merging Bash sources

James Laver james.laver at
Wed Nov 11 01:19:30 GMT 2009

On Wed, Nov 11, 2009 at 1:03 AM, Simon Wistow <simon at> wrote:
> I have a small problem in that I'm trying to modify a bash script so
> that currently does this
>    . config
>    # then inspect command line args
>    getArgs
> so that you can specify the config file on the command line. Which
> necessarily requires do
>    config_file="config"
>    # inspect command line args first
>    getArgs
>    . ${config_file}

Perhaps I'm overlooking something obvious, but why don't you just parse twice?

Failing that, you could opt to use environment variables for extra
config files, so you'd call it like

MYSCRIPT_CONFIG_FILE=/path/to/config ./

That way you eliminate the first pass of the arguments.


More information about the mailing list