From aa477e47c6b29cf579941d3107ea98a3ab2ce728 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:58:12 +0800 Subject: [PATCH] mail can't write to mbox * When issuing quit command (q) I was seeing the error: Failed to write to /home/ranch/mbox: No such file or directory * Something was wrong because the file did exist * The error message printed $self->file but the path opened was $of, which had a prepended ">" * Possibly this is a hangover from previously switching to 3-argument form of open() --- bin/mail | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bin/mail b/bin/mail index 5a580e17..cbe7ada6 100755 --- a/bin/mail +++ b/bin/mail @@ -425,13 +425,10 @@ sub write { my $self=shift; my $wa=shift; - $of=">" . $self->file; - if (exists $$wa{append} ) { - $of=">$of"; - } + my $mode = exists $$wa{append} ? '>>' : '>'; my $alt_msg="\"" . $self->file . "\" "; $alt_msg.=(-e $self->file)?"[Appended]":"[New File]"; - if (! open(MBOX, '<', $of )) { + if (!open(MBOX, $mode, $self->file)) { warn "Failed to write to ", $self->file, ": $!\n"; return; }