On Sat, Jun 02, 2007 at 09:29:55AM -0700, Guillermo A. Amaral wrote:
> Anybody willing to try out my bash config library?
> I also made this little utility to help out with my Arch and Gentoo server 
> updates.
> 
>   The main part is the library that can be used in many configuration 
> utilities, It allows you to parse, modify bash config scripts and save there 
> structure by only modifying the variables that got updated in there original 
> location in the file.
> 
>   I made a basic command based utility for the library so I can test it out, 
> the app is called 'bashcfg' and it accepts 1 input file and multiple 
> commands. Example:
> 
>   $ bashcfg /etc/rc.conf +DAEMONS=kdm -DAEMONS=xdm
> 
> This command will append add 'kdm' and at the same time remove 'xdm' from the 
> DAEMONS array in rc.conf .

Sounds like a typical sed job:

bashcfg_add () 
{ 
    sed "s/$1=(\([^)]*\))/$1=(\1 $2)/"
}
bashcfg_remove () 
{ 
    sed "s/$1=(\([^)]*\)$2\([^)]*\))/$1=(\1\2)/"
}

</etc/rc.conf bashcfg_add DAEMONS kdm|bashcfg_remove DAEMONS xdm

Why implement this in C++?

Jürgen


_______________________________________________
arch mailing list
[email protected]
http://archlinux.org/mailman/listinfo/arch

Reply via email to