user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/2] edit: minor bug fixes
@ 2019-11-08 20:20 Eric Wong
  2019-11-08 20:20 ` [PATCH 1/2] edit: propagate correct editor exit code Eric Wong
  2019-11-08 20:20 ` [PATCH 2/2] edit: check for write errors writing "From_" line Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2019-11-08 20:20 UTC (permalink / raw)
  To: meta

A few minor bugfixes I noticed while working on other stuff...

Eric Wong (2):
  edit: propagate correct editor exit code
  edit: check for write errors writing "From_" line

 script/public-inbox-edit | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] edit: propagate correct editor exit code
  2019-11-08 20:20 [PATCH 0/2] edit: minor bug fixes Eric Wong
@ 2019-11-08 20:20 ` Eric Wong
  2019-11-08 20:20 ` [PATCH 2/2] edit: check for write errors writing "From_" line Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2019-11-08 20:20 UTC (permalink / raw)
  To: meta

exit($?) is never correct, since ($? >> 8) is needed to extract
the correct exit code, as other information (e.g. such as signal)
is encoded in $? in addition to the exit code.
---
 script/public-inbox-edit | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index f2090abf..24b7ed8b 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -149,7 +149,11 @@ retry_edit:
 			chomp(my $op = <STDIN> || '');
 			$op = lc($op);
 			goto retry_edit if $op eq 'r';
-			exit $? if $op eq 'q';
+			if ($op eq 'q') {
+				# n.b. we'll lose the exit signal, here,
+				# oh well; "q" is user-specified anyways.
+				exit($? >> 8);
+			}
 			last if $op eq 'c'; # continuing
 			print STDERR "\`$op' not recognized\n";
 		}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] edit: check for write errors writing "From_" line
  2019-11-08 20:20 [PATCH 0/2] edit: minor bug fixes Eric Wong
  2019-11-08 20:20 ` [PATCH 1/2] edit: propagate correct editor exit code Eric Wong
@ 2019-11-08 20:20 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2019-11-08 20:20 UTC (permalink / raw)
  To: meta

We need to check every print to a regular file for errors,
because storage devices inevitably fail.
---
 script/public-inbox-edit | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index 24b7ed8b..43ce9900 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -130,7 +130,8 @@ foreach my $to_edit (values %$found) {
 	my $tmp = $$old_raw;
 	if (!$opt->{raw}) {
 		my $oid = $smsg->{blob};
-		print $edit_fh "From mboxrd\@$oid Thu Jan  1 00:00:00 1970\n";
+		print $edit_fh "From mboxrd\@$oid Thu Jan  1 00:00:00 1970\n"
+			or die "failed to write From_ line: $!";
 		$tmp =~ s/^(>*From )/>$1/gm;
 	}
 	print $edit_fh $tmp or

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-08 20:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 20:20 [PATCH 0/2] edit: minor bug fixes Eric Wong
2019-11-08 20:20 ` [PATCH 1/2] edit: propagate correct editor exit code Eric Wong
2019-11-08 20:20 ` [PATCH 2/2] edit: check for write errors writing "From_" line Eric Wong

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).