]> git.proxmox.com Git - pve-common.git/commitdiff
add keeplocale parameter to run_command
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 28 Feb 2017 11:06:35 +0000 (12:06 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 9 Mar 2017 08:24:52 +0000 (09:24 +0100)
since the "lang" param has not worked, introduce a "keeplocale"
parameter instead.

the default behaviour is the same (set LC_ALL to 'C'), but we can use
the parameter to keep the locale from the host (eg. for the vncshell)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/PVE/Tools.pm

index 69c87304396129fe7dc7d70847299fb0db256b84..fe35ef225e46f35d52d5c374c00e3738b8b3871b 100644 (file)
@@ -350,6 +350,7 @@ sub run_command {
     my $output;
     my $afterfork;
     my $noerr;
+    my $keeplocale;
 
     eval {
 
@@ -374,6 +375,8 @@ sub run_command {
                $afterfork = $param{$p};
            } elsif ($p eq 'noerr') {
                $noerr = $param{$p};
+           } elsif ($p eq 'keeplocale') {
+               $keeplocale = $param{$p};
            } else {
                die "got unknown parameter '$p' for run_command\n";
            }
@@ -397,13 +400,10 @@ sub run_command {
        my $writer = $input && $input =~ m/^<&/ ? $input : IO::File->new();
        my $error  = IO::File->new();
 
-       # try to avoid locale related issues/warnings
-       my $lang = $param{lang} || 'C';
-
        my $orig_pid = $$;
 
        eval {
-           local $ENV{LC_ALL} = $lang;
+           local $ENV{LC_ALL} = 'C' if !$keeplocale;
 
            # suppress LVM warnings like: "File descriptor 3 left open";
            local $ENV{LVM_SUPPRESS_FD_WARNINGS} = "1";