Skip to content

Commit

Permalink
ed: honour -s flag for w & e commands (#931)
Browse files Browse the repository at this point in the history
* In BSD ed, the -s flag is for running an ed script
* Modified buffers don't prevent the editor from quitting or editing a new file in this mode
* GNU ed doesn't seem to follow this, but to me the GNU interpretation seems inconsistent with the meaning of -s
  • Loading branch information
mknos authored Jan 24, 2025
1 parent 6228571 commit 28dcd04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ my $UndoLine;
my $PRINT_NUM = 1;
my $PRINT_BIN = 2;

our $VERSION = '0.27';
our $VERSION = '0.28';

my @ESC = (
'\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\a',
Expand Down Expand Up @@ -744,7 +744,7 @@ sub edEdit {
my(@tmp_lines, $chars, $fh, $filename);

return E_ADDREXT if defined($adrs[0]) or defined($adrs[1]);
if ($NeedToSave && $QuestionsMode && !$UserHasBeenWarned) {
if ($NeedToSave && $QuestionsMode && !$UserHasBeenWarned && !$Scripted) {
$UserHasBeenWarned = 1;
return E_UNSAVED;
}
Expand Down Expand Up @@ -913,7 +913,7 @@ sub edQuit {
return E_ADDREXT if defined $adrs[0];
return E_ARGEXT if defined $args[0];

if ($QuestionMode && $NeedToSave && !$UserHasBeenWarned) {
if ($QuestionMode && $NeedToSave && !$UserHasBeenWarned && !$Scripted) {
$UserHasBeenWarned = 1;
return E_UNSAVED;
}
Expand Down

0 comments on commit 28dcd04

Please sign in to comment.