[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: .ini files in bash?



Once upon a time David Baron said...
> On Monday 29 November 2004 16:04, Sam Watkins wrote:
> > If you want to see what variables are set, type:
> >
> >   set
> >
> > this shows shell functions too.
> >
> > you can save these variables (and possibly functions) in a file:
> >
> >   set > myvariables
> >
> > and restore them again:
> >
> >   source ./myvariables
> >
> > or if you're lazy to type source:
> >
> >   . ./myvariables
> 
> set > myvariables does through every (I mean everything) somehow set in 
> ~/myvariables.
> 
> However, source ~/myvariables does NOT work. Script simply aborts. It is 
> finding the file, otherwize, get error message.

Ok. I got bored and spend a minute writing this:

function savevars()
{
    for var in "$@" ; do
        eval "echo $var=\\\"\$$var\\\""
    done
}


Just call it like:
savevars VAR1 VAR2 VAR3 >file

then load the vars with:
source ./file




Reply to: