| 1 | package Psh::Builtins::Printenv; | ||
| 2 | |||
| 3 | require Psh::Support::Env; | ||
| 4 | require Psh::Util; | ||
| 5 | |||
| 6 | =item * C<printenv NAME [NAME ...]> | ||
| 7 | |||
| 8 | Displays the named environment variables | ||
| 9 | |||
| 10 | =cut | ||
| 11 | |||
| 12 | sub bi_printenv | ||
| 13 | { | ||
| 14 | my @names= @{$_[1]}; | ||
| 15 | if (@names) { | ||
| 16 | foreach (@names) { | ||
| 17 | Psh::Util::print_out($ENV{uc($_)}."\n"); | ||
| 18 | } | ||
| 19 | } else { | ||
| 20 | while (my ($key,$val)= each %ENV) { | ||
| 21 | Psh::Util::print_out("$key=$val\n"); | ||
| 22 | } | ||
| 23 | } | ||
| 24 | return (1,undef); | ||
| 25 | } | ||
| 26 | |||
| 27 | |||
| 28 | sub cmpl_printenv { | ||
| 29 | my( $text, $pre, $start, $line, $startchar) = @_; | ||
| 30 | return 1,grep { Psh::Util::starts_with($_,$text)} keys %ENV; | ||
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | 1; |