Skip to content

Commit 478c54a

Browse files
authored
ed: initial edEdit() errors were silenced
* When the editor starts there is an implicit call to edEdit(), which will either load a named file or start the editor with an empty buffer * edEdit() is also the handler for the commands E and e * Starting ed with an empty string file argument is not valid * Starting ed with a filename ending in '/' is not valid * edEdit() returns an error string; write a little function to handle the error * Special case: when starting ed with a non-existent file, a print a warning but not the '?' prompt (this is not a serious error for initial edEdit() because there is no editor buffer yet)
1 parent 781bd3c commit 478c54a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

bin/ed

+14-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ my $UndoLine;
100100
my $PRINT_NUM = 1;
101101
my $PRINT_BIN = 2;
102102

103-
our $VERSION = '0.29';
103+
our $VERSION = '0.30';
104104

105105
my @ESC = (
106106
'\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\a',
@@ -217,9 +217,21 @@ $args[0] = shift;
217217
$args[0] = undef if (defined($args[0]) && $args[0] eq '-');
218218
Usage() if @ARGV;
219219
$Scripted = $opt{'s'};
220-
edEdit(0);
220+
init_edit();
221221
input() while 1;
222222

223+
sub init_edit {
224+
my $err = edEdit(0);
225+
if ($err) {
226+
if ($err eq E_OPEN) { # silence warning
227+
$Error = $err;
228+
} else {
229+
edWarn($err);
230+
}
231+
}
232+
return;
233+
}
234+
223235
sub input {
224236
$command = $commandsuf = '';
225237
@adrs = ();

0 commit comments

Comments
 (0)