From 6d1e623c71d4491ac76f8a442e6a4918cc4193ab Mon Sep 17 00:00:00 2001 From: Rick Myers Date: Sat, 18 May 2019 12:37:08 -0400 Subject: [PATCH 1/3] Remove POSIX::tmpnam() deprecation warning, per GitHub issue #14 --- CHANGES.pod | 13 +++++++++++++ Makefile.PL | 1 + lib/Psh/OS.pm | 8 +++++++- lib/Psh/OS/Unix.pm | 14 +++++--------- lib/Psh/OS/Win.pm | 13 +++++-------- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/CHANGES.pod b/CHANGES.pod index b0997b6..1074ef6 100644 --- a/CHANGES.pod +++ b/CHANGES.pod @@ -25,6 +25,19 @@ A reverse-chronological ordered list of changes ############################################################################### ############################################################################### +=head1 1.9 [????-??-??] + +=head2 Fixes + +=over 4 + +=item * + +Removed POSIX::tempnam() deprecation warning. + +=back + + =head1 1.8.1 [2007-07-20] =head2 Fixes diff --git a/Makefile.PL b/Makefile.PL index 2150549..143689b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -74,6 +74,7 @@ WriteMakefile ( PREREQ_PM => { 'Cwd' => '0', 'File::Spec' => '0', + 'IO::File' => '0', }, MAN1PODS => $pods, PM => $pms, diff --git a/lib/Psh/OS.pm b/lib/Psh/OS.pm index 56190ef..d8c2d68 100644 --- a/lib/Psh/OS.pm +++ b/lib/Psh/OS.pm @@ -160,10 +160,16 @@ sub fb_signal_description { } # Return a name for a temp file - +# Legacy security risk, but leaving in case +# anyone's using it. We're already loading +# POSIX anyway, and it gives its own warning. sub fb_tmpnam { return POSIX::tmpnam(); } +sub fb_tmpfile { + require IO::File; + return IO::File::new_tmpfile(); +} sub fb_get_window_size {} sub fb_remove_signal_handlers {1} diff --git a/lib/Psh/OS/Unix.pm b/lib/Psh/OS/Unix.pm index e050b94..6d2c398 100644 --- a/lib/Psh/OS/Unix.pm +++ b/lib/Psh/OS/Unix.pm @@ -86,23 +86,19 @@ sub get_known_hosts { # void display_pod(text) # sub display_pod { - my $tmp= Psh::OS::tmpnam(); + my $tmpfh= Psh::OS::tmpfile(); my $text= shift; - local *TMP; - open( TMP,">$tmp"); - print TMP $text; - close(TMP); + print $tmpfh $text; + $tmpfh->flush(); + $tmpfh->seek(0,0); # rewind eval { require Pod::Text; - open STDOUT_SAVE, ">&", STDOUT; - Pod::Text::pod2text($tmp,*STDOUT_SAVE); + Pod::Text::pod2text($tmpfh); }; Psh::Util::print_debug_class('e',"Error: $@") if $@; print $text if $@; - - unlink($tmp); } sub get_home_dir { diff --git a/lib/Psh/OS/Win.pm b/lib/Psh/OS/Win.pm index df5fec1..cc92cfd 100644 --- a/lib/Psh/OS/Win.pm +++ b/lib/Psh/OS/Win.pm @@ -63,21 +63,18 @@ sub get_known_hosts { # void display_pod(text) # sub display_pod { - my $tmp= Psh::OS::tmpnam(); + my $tmpfh= Psh::OS::tmpfile(); my $text= shift; - open( TMP,">$tmp"); - print TMP $text; - close(TMP); + print $tmpfh $text; + $tmpfh->flush(); + $tmpfh->seek(0,0); # rewind eval { require Pod::Text; - open STDOUT_SAVE, ">&", STDOUT; - Pod::Text::pod2text($tmp,*STDOUT_SAVE); + Pod::Text::pod2text($tmpfh); }; print $text if $@; - - unlink($tmp); } sub inc_shlvl { From 0b172d1c161ddfb7d6c9a3e67142e52f900e96c8 Mon Sep 17 00:00:00 2001 From: Rick Myers Date: Sat, 18 May 2019 12:37:36 -0400 Subject: [PATCH 2/3] Fix over-escaping problem, per GitHub issue #9 --- CHANGES.pod | 4 ++++ lib/Psh/Parser.pm | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGES.pod b/CHANGES.pod index 1074ef6..24444b3 100644 --- a/CHANGES.pod +++ b/CHANGES.pod @@ -35,6 +35,10 @@ A reverse-chronological ordered list of changes Removed POSIX::tempnam() deprecation warning. +=item * + +Fixed over-escaping problem. "\\\\" now evaluates as "\\" instead of "\". + =back diff --git a/lib/Psh/Parser.pm b/lib/Psh/Parser.pm index 7137c83..f9181c1 100644 --- a/lib/Psh/Parser.pm +++ b/lib/Psh/Parser.pm @@ -264,7 +264,19 @@ sub remove_backslash { $text=~ s/\\e/\e/g; $text=~ s/\\(0[0-7][0-7])/chr(oct($1))/ge; $text=~ s/\\(x[0-9a-fA-F][0-9a-fA-F])/chr(oct($1))/ge; - $text=~ s/\\(.)/$1/g; + # + #$text=~ s/\\(.)/$1/g; + # + # this breaks constructs like: + # > print "\\\\\n" + # \ + # > + # should be: + # > print "\\\\\n" + # \\ + # > + # + return $text; } From 6a83257757cfd437256143dac10d484353ad1c98 Mon Sep 17 00:00:00 2001 From: Rick Myers Date: Sat, 18 May 2019 12:37:52 -0400 Subject: [PATCH 3/3] Add Win32 module prereqs to Makefile.PL --- CHANGES.pod | 4 ++++ Makefile.PL | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGES.pod b/CHANGES.pod index 24444b3..8488d90 100644 --- a/CHANGES.pod +++ b/CHANGES.pod @@ -39,6 +39,10 @@ Removed POSIX::tempnam() deprecation warning. Fixed over-escaping problem. "\\\\" now evaluates as "\\" instead of "\". +=item * + +Added Win32 module prereqs to Makefile.PL. + =back diff --git a/Makefile.PL b/Makefile.PL index 143689b..64e634c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -75,6 +75,16 @@ WriteMakefile ( 'Cwd' => '0', 'File::Spec' => '0', 'IO::File' => '0', + ( $^O eq 'MSWin32' + ? ( + 'Win32' => '0', + 'Win32::TieRegistry' => '0.20', + 'Win32::Process' => '0', + 'Win32::Console' => '0', + 'Win32::NetAdmin' => '0', + ) + : () + ), }, MAN1PODS => $pods, PM => $pms,