Skip to content

Commit

Permalink
ed: retire non-standard debug flag -d (#793)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mknos authored Nov 11, 2024
1 parent 03dae73 commit 2c9634f
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ use constant E_PATTERN => 'invalid pattern delimiter';
use constant E_NOMATCH => 'no match';
use constant E_NOPAT => 'no previous pattern';

use constant EX_SUCCESS => 0;
use constant EX_FAILURE => 1;

# important globals

my $CurrentLineNum = 0; # default to before first line.
Expand Down Expand Up @@ -109,7 +112,7 @@ my $NO_QUESTIONS_MODE = 0;
my $PRINT_NUM = 1;
my $PRINT_BIN = 2;

our $VERSION = '0.14';
our $VERSION = '0.15';

my @ESC = (
'\\000', '\\001', '\\002', '\\003', '\\004', '\\005', '\\006', '\\a',
Expand Down Expand Up @@ -193,11 +196,11 @@ $SIG{HUP} = sub {
close $fh;
}
}
exit 1;
exit EX_FAILURE;
};

my %opt;
getopts('dp:s', \%opt) or Usage();
getopts('p:s', \%opt) or Usage();
if (defined $opt{'p'}) {
$Prompt = $opt{'p'};
}
Expand All @@ -223,14 +226,6 @@ sub input {
edWarn(E_CMDBAD);
return;
}
if ($opt{'d'}) {
print "command: /$command/ ";
print "adrs[0]: /$adrs[0]/ " if defined($adrs[0]);
print "adrs[1]: /$adrs[1]/ " if defined($adrs[1]);
print "args[0]: /$args[0]/ " if defined($args[0]);
print "\n";
}

# sanity check addresses
foreach my $ad (@adrs) {
next unless defined $ad;
Expand Down Expand Up @@ -265,7 +260,7 @@ sub input {

sub VERSION_MESSAGE {
print "ed version $VERSION\n";
exit 0;
exit EX_SUCCESS;
}

sub maxline {
Expand Down Expand Up @@ -662,7 +657,7 @@ sub edWrite {
print "$chars\n" unless ($SupressCounts);

if ($qflag) {
exit 0;
exit EX_SUCCESS;
}
}

Expand Down Expand Up @@ -851,8 +846,7 @@ sub edQuit {
edWarn(E_UNSAVED);
return;
}

exit 0;
exit EX_SUCCESS;
}

#
Expand Down Expand Up @@ -1100,7 +1094,8 @@ sub edSearchGlobal {
}

sub Usage {
die "Usage: ed [-p prompt] [-ds] [file]\n";
print "usage: ed [-p prompt] [-s] [file]\n";
exit EX_FAILURE;
}

#
Expand Down Expand Up @@ -1129,7 +1124,7 @@ ed - text editor
=head1 SYNOPSIS
ed [-p prompt] [-ds] [file]
ed [-p prompt] [-s] [file]
=head1 DESCRIPTION
Expand Down Expand Up @@ -1170,10 +1165,6 @@ The following options are available:
=over 4
=item -d
Print debugging information on standard output.
=item -p STRING
Use the specified STRING as a command prompt.
Expand Down

0 comments on commit 2c9634f

Please sign in to comment.