Re: .ini files in bash?

From: Cameron Hutchison (camh+dl_at_xdna.net)
Date: 11/29/04

  • Next message: David Mandelberg: "Re: Full replacement of MS"
    Date: Tue, 30 Nov 2004 08:11:54 +1100
    To: debian-user@lists.debian.org
    
    

    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

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: David Mandelberg: "Re: Full replacement of MS"

    Relevant Pages

    • Re: [opensuse] bash - why doesnt the tldp bash beginners guide for loop example work?
      ... newlines and not spaces. ... And if the script is more than just a quick one-liner, ... Within bash one may use in shell functions ... local IFS ...
      (SuSE)
    • Re: What is the name for
      ... I have a script v which edits any file in the current directory ... than the equivalent sed or awk script. ... Shell Scripting Recipes: | My code in this post, if any, ...
      (comp.unix.shell)
    • Re: Weird PATH problem
      ... Another path item is added by a Java script ... I use a set of shell functions to manipulate the PATH variable. ... Shell Scripting Recipes: | My code in this post, if any, ...
      (alt.os.linux)