From f59a33c43337111906246e3c26df2445886255bb Mon Sep 17 00:00:00 2001 From: b Date: Wed, 14 Jun 2023 23:15:22 +0000 Subject: [PATCH] exec with encoding --- botm_common.pm | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/botm_common.pm b/botm_common.pm index 0d6b4dd..0e8c405 100644 --- a/botm_common.pm +++ b/botm_common.pm @@ -24,21 +24,19 @@ use Encode::Locale; use Encode ('encode', 'decode'); use Exporter; -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); -# vX.Y.Z: X YYYZZZ -$VERSION = 1.000010; -@ISA = qw(Exporter); -@EXPORT = (); -@EXPORT_OK = ( +our $VERSION = '1.0.11'; +our @ISA = qw(Exporter); +our @EXPORT = (); +our @EXPORT_OK = ( 'read_data_file', 'write_data_file', 'url_encode', 'url_decode', 'url_query_encode', 'url_query_decode', 'split_url', 'join_url', 'merge_url', 'html_entity_encode_dec', 'html_entity_encode_hex', 'html_entity_encode_name', 'html_entity_decode', - 'join_path', 'make_temp_path' + 'join_path', 'make_temp_path', + 'system_encoded', 'exec_encoded' ); -%EXPORT_TAGS = (); @@ -94,6 +92,32 @@ sub make_temp_path { return join_path('/', $dir, $filename); } +sub system_encoded { + (my $cmd, my @arg) = @_; + my @newarg; + + my $newcmd = encode('locale_fs', $cmd); + + foreach my $a (@arg) { + push @newarg, encode('locale', $a); + } + + return system $newcmd, @newarg; +} + +sub exec_encoded { + (my $cmd, my @arg) = @_; + my @newarg; + + my $newcmd = encode('locale_fs', $cmd); + + foreach my $a (@arg) { + push @newarg, encode('locale', $a); + } + + return exec $newcmd, @newarg; +} + ################## -- 2.30.2