#! /usr/bin/perl -w

use strict;

use lib '/usr/share/perl5';

use Lire::Program;
use Lire::Config;
use Lire::Config::Legacy;
use Lire::Utils qw/shell_quote/;
use Lire::Logger;
use Carp;

Lire::Config->init;

# Output invalid configuration warning messages
# at debug level since the variables isn't necessarily
# needed
local $SIG{__WARN__} = sub { lr_debug( @_ ) };
my $spec = Lire::Config->config_spec;
foreach my $var ( $spec->components ) {
    print Lire::Config->get_var( $var->name )->as_shell_var, "\n";
}

my @export = ();
while ( my ( $old_var, $new_var ) = each %Lire::Config::Legacy::map ) {
    my $var = Lire::Config->get_var( $new_var );
    print $old_var . "=" . shell_quote( $var->as_value ). "\n";
    push @export, $old_var;
}
print "export ", join( " ", @export ), "\n"
  if @export;

exit 0;

__END__

=pod

=head1 NAME

lr_environment - Export Lire configuration in shell script form

=head1 SYNOPSIS 

eval `B<lr_environment>`

=head1 DESCRIPTION

The B<lr_environment> command is used to import the Lire configuration
in Lire shell scripts.

All of Lire configuration variables will be written in a format that
can be evaled by the shell.

Shell scripts don't usually have to use that command, since it is done
by the F<defaults> file sourced by each command.

The old names used by when the configuration was done in shell script
are also exported by this script for backward compatibility.

=head1 AUTHOR

Francis J. Lacoste <flacoste@logreport.org>

=head1 VERSION

$Id: lr_environment.in,v 1.8 2004/01/21 07:23:00 wsourdeau Exp $

=head1 COPYRIGHT

Copyright (C) 2003 Stichting LogReport Foundation LogReport@LogReport.org

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html or write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.

=cut

# Local Variables:
# mode: cperl
# End:




