From 8a411744aa3161a6fd5b262a3726eaa752b4d499 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Fri, 13 Oct 2023 22:55:24 +0800 Subject: [PATCH] tee: null mode param passed to open() * Sometimes tee fails to open a file for writing because of a confusing filename guard regex echo yo | perl tee . '|o|' tee: cannot open .: Is a directory Unknown open() mode '' at tee line 45. * '|o|' is a valid filename on my system if it is quoted like this * GNU tee doesn't complain about this usage (aside from complaining about the directory argument '.') * $mode is already determined based on -a option * Making decisions based on the filename seems incorrect so just simplify open() --- bin/tee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/tee b/bin/tee index 3996e7b5..04704d93 100755 --- a/bin/tee +++ b/bin/tee @@ -42,7 +42,7 @@ if ($nostdout) { $| = 1 if $unbuffer; for (@ARGV) { - if (!open($fh, (/^[^>|]/ && $mode), $_)) { + if (!open($fh, $mode, $_)) { warn "$0: cannot open $_: $!\n"; # like sun's; i prefer die $status++; next;