]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-edit
edit: propagate correct editor exit code
[public-inbox.git] / script / public-inbox-edit
index 2e2c761620e154da65a395f6d9c6a12a756cb14f..24b7ed8b2d220bb7a1bc090c7228e2a7fb608e21 100755 (executable)
@@ -65,7 +65,7 @@ sub find_mid ($) {
 
 sub show_cmd ($$) {
        my ($ibx, $smsg) = @_;
-       " GIT_DIR=$ibx->{mainrepo}/all.git \\\n    git show $smsg->{blob}\n";
+       " GIT_DIR=$ibx->{inboxdir}/all.git \\\n    git show $smsg->{blob}\n";
 }
 
 sub show_found () {
@@ -138,7 +138,7 @@ foreach my $to_edit (values %$found) {
 
        # run the editor, respecting spaces/quote
 retry_edit:
-       if (system(qw(sh -c), qq(eval "$editor" '"\$@"'), '--', $edit_fn)) {
+       if (system(qw(sh -c), $editor.' "$@"', $editor, $edit_fn)) {
                if (!(-t STDIN) && !$opt->{force}) {
                        die "E: $editor failed: $?\n";
                }
@@ -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";
                }