Skip to content

Commit 2c9634f

Browse files
authored
ed: retire non-standard debug flag -d (#793)
* This version of ed is different to the C versions in that it's trivial to run it under the perl debugger * The debug info produced by running "ed -d" is limited, and other versions of ed don't provide an equivalent option * Sync usage string + SYNOPSIS * Add symbolic exit codes as done in other scripts
1 parent 03dae73 commit 2c9634f

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

bin/ed

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ use constant E_PATTERN => 'invalid pattern delimiter';
7979
use constant E_NOMATCH => 'no match';
8080
use constant E_NOPAT => 'no previous pattern';
8181

82+
use constant EX_SUCCESS => 0;
83+
use constant EX_FAILURE => 1;
84+
8285
# important globals
8386

8487
my $CurrentLineNum = 0; # default to before first line.
@@ -109,7 +112,7 @@ my $NO_QUESTIONS_MODE = 0;
109112
my $PRINT_NUM = 1;
110113
my $PRINT_BIN = 2;
111114

112-
our $VERSION = '0.14';
115+
our $VERSION = '0.15';
113116

114117
my @ESC = (
115118
'\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\a',
@@ -193,11 +196,11 @@ $SIG{HUP} = sub {
193196
close $fh;
194197
}
195198
}
196-
exit 1;
199+
exit EX_FAILURE;
197200
};
198201

199202
my %opt;
200-
getopts('dp:s', \%opt) or Usage();
203+
getopts('p:s', \%opt) or Usage();
201204
if (defined $opt{'p'}) {
202205
$Prompt = $opt{'p'};
203206
}
@@ -223,14 +226,6 @@ sub input {
223226
edWarn(E_CMDBAD);
224227
return;
225228
}
226-
if ($opt{'d'}) {
227-
print "command: /$command/ ";
228-
print "adrs[0]: /$adrs[0]/ " if defined($adrs[0]);
229-
print "adrs[1]: /$adrs[1]/ " if defined($adrs[1]);
230-
print "args[0]: /$args[0]/ " if defined($args[0]);
231-
print "\n";
232-
}
233-
234229
# sanity check addresses
235230
foreach my $ad (@adrs) {
236231
next unless defined $ad;
@@ -265,7 +260,7 @@ sub input {
265260

266261
sub VERSION_MESSAGE {
267262
print "ed version $VERSION\n";
268-
exit 0;
263+
exit EX_SUCCESS;
269264
}
270265

271266
sub maxline {
@@ -662,7 +657,7 @@ sub edWrite {
662657
print "$chars\n" unless ($SupressCounts);
663658

664659
if ($qflag) {
665-
exit 0;
660+
exit EX_SUCCESS;
666661
}
667662
}
668663

@@ -851,8 +846,7 @@ sub edQuit {
851846
edWarn(E_UNSAVED);
852847
return;
853848
}
854-
855-
exit 0;
849+
exit EX_SUCCESS;
856850
}
857851

858852
#
@@ -1100,7 +1094,8 @@ sub edSearchGlobal {
11001094
}
11011095

11021096
sub Usage {
1103-
die "Usage: ed [-p prompt] [-ds] [file]\n";
1097+
print "usage: ed [-p prompt] [-s] [file]\n";
1098+
exit EX_FAILURE;
11041099
}
11051100

11061101
#
@@ -1129,7 +1124,7 @@ ed - text editor
11291124
11301125
=head1 SYNOPSIS
11311126
1132-
ed [-p prompt] [-ds] [file]
1127+
ed [-p prompt] [-s] [file]
11331128
11341129
=head1 DESCRIPTION
11351130
@@ -1170,10 +1165,6 @@ The following options are available:
11701165
11711166
=over 4
11721167
1173-
=item -d
1174-
1175-
Print debugging information on standard output.
1176-
11771168
=item -p STRING
11781169
11791170
Use the specified STRING as a command prompt.

0 commit comments

Comments
 (0)