Skip to content

Commit

Permalink
Only encode @argv once.
Browse files Browse the repository at this point in the history
  • Loading branch information
schwern committed Feb 15, 2011
1 parent 60bfd25 commit 022b4cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 8 additions & 4 deletions Changes
Expand Up @@ -3,14 +3,18 @@
* Added capture(), from Capture::Tiny, to capture output to STDOUT and
STDERR [github 178]

Windows Fixes
* Fix t/center.t (Myf White)
* Fix t/command_line_wrapper.t (Myf White)

New Docs
* Added perl5ifaq entries for capturing output from a command using
capture()

Bug Fixes
* perl5i will no longer double encode @ARGV if it's loaded multiple times.
[github 176]

Windows Fixes
* Fix t/center.t (Myf White)
* Fix t/command_line_wrapper.t (Myf White)

Misc
* The dependency on true.pm will no longer confuse some YAML parsers.

Expand Down
8 changes: 7 additions & 1 deletion lib/perl5i/2.pm
Expand Up @@ -84,7 +84,8 @@ sub import {
(\&capture)->alias($caller, "capture");

# utf8ify @ARGV
$_ = Encode::decode('utf8', $_) for @ARGV;
state $have_encoded_argv = 0;
_encode_argv() unless $have_encoded_argv++;

# Current lexically active major version of perl5i.
$^H{perl5i} = 2;
Expand Down Expand Up @@ -187,3 +188,8 @@ sub capture(&;@) {
my $func = $captures->{$opts};
return $func->($code);
}

sub _encode_argv {
$_ = Encode::decode('utf8', $_) for @ARGV;
return;
}

0 comments on commit 022b4cc

Please sign in to comment.