]> Sergey Matveev's repositories - public-inbox.git/commitdiff
edit: propagate correct editor exit code
authorEric Wong <e@80x24.org>
Fri, 8 Nov 2019 20:20:17 +0000 (20:20 +0000)
committerEric Wong <e@80x24.org>
Fri, 8 Nov 2019 20:20:59 +0000 (20:20 +0000)
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

index f2090abfe583992ab6c398213438c3a76a3775d3..24b7ed8b2d220bb7a1bc090c7228e2a7fb608e21 100755 (executable)
@@ -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";
                }