#! /usr/bin/perl -w

use strict;

use lib '/usr/share/perl5';

use Carp;

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

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 ) {
    # Skip var which aren't valid shell variable names.
    next unless $var->name() =~ /^\w+$/;
    print Lire::Config->get_var( $var->name )->as_shell_var, "\n";
}

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.12 2006/07/23 13:16:33 vanbaal 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.

=cut

# Local Variables:
# mode: cperl
# End:
