Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / Psh / Builtins / Export.pm
CommitLineData
86530b38
AT
1package Psh::Builtins::Export;
2
3require Psh::Support::Env;
4require Psh::Options;
5require Psh::Util;
6
7=item * C<export VAR [=VALUE]>
8
9Just like setenv, below, except that it also ties the variable (in the
10Perl sense) so that subsequent changes to the variable automatically
11affect the environment. Variables who are lists and appear in option
12'array_exports' will also by tied to the array of the same name.
13Note that the variable must be specified without any Perl specifier
14like C<$> or C<@>.
15
16=cut
17
18sub bi_export
19{
20 my $var = Psh::Support::Env::do_setenv(@_);
21 if ($var) {
22 my @result = Psh::PerlEval::protected_eval("tied(\$$var)");
23 my $oldtie = $result[0];
24 if (defined($oldtie)) {
25 if (ref($oldtie) ne 'Env') {
26 Psh::Util::print_warning_i18n('bi_export_tied',$var,$oldtie);
27 }
28 } else {
29 Psh::PerlEval::protected_eval("use Env '$var';");
30 my $ae= Psh::Options::get_option('array_exports');
31 if( $ae and $ae->{$var}) {
32 eval {
33 require Env::Array;
34 };
35 if( ! $@) {
36 Psh::PerlEval::protected_eval("use Env::Array qw($var $ae->{var});",'hide');
37 }
38 }
39 }
40 } else {
41 Psh::Util::print_error_i18n('usage_export');
42 return (0,undef);
43 }
44 return (1,undef);
45}
46
471;
48