Skip to content

Commit

Permalink
ed: add --version (#637)
Browse files Browse the repository at this point in the history
* Simplify getopt by removing -v flag which BSD versions of ed don't support (neither is -v a standard ed flag)
* Remove TODO comment related to adding 'x' command; this command is not supported on OpenBSD (nor FreeBSD from what I see in its manual)
* Remove comment with outdated url
* Sync SYNOPSIS and usage string
  • Loading branch information
mknos authored Jun 4, 2024
1 parent 4a87acf commit b140a8e
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ License: gpl
# Why?:
# - Because ed is "always there" (or supposed to be anyways)
# - Because I violently dislike vi (on Unix) and NOTEPAD on WinDoze
# - Also see the "Perl Power Tools: The Unix Reconstruction Project"
# at http://language.perl.com/ppt/
# - Because working on this is more fun than Y2K testing !
#
# Who:
Expand Down Expand Up @@ -55,7 +53,6 @@ License: gpl
# k - mark
# u - undo
# v - global command "inVerted"
# x - get encryption key
#
# - Create regression test suite...test against "real" ed.
# - add a "-e" flag to allow it to be used in sed(1) like fashion.
Expand Down Expand Up @@ -111,7 +108,7 @@ my $NO_QUESTIONS_MODE = 0;
my $PRINT_NUM = 1;
my $PRINT_BIN = 2;

my $VERSION = '0.3';
our $VERSION = '0.4';

my %ESC = (
7 => '\a',
Expand Down Expand Up @@ -173,15 +170,10 @@ $SIG{HUP} = sub {
};

my %opt;
getopts('dp:sv', \%opt) or Usage();
getopts('dp:s', \%opt) or Usage();
if (defined $opt{'p'}) {
$Prompt = $opt{'p'};
}
if ($opt{'v'}) {
warn "perl ed version $VERSION\n";
$EXTENDED_MESSAGES = 1;
}

$args[0] = shift;
$args[0] = undef if (defined($args[0]) && $args[0] eq '-');
Usage() if @ARGV;
Expand Down Expand Up @@ -250,6 +242,11 @@ while (1) {
}
}

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

sub maxline {
my $n = $#lines;
if ($n < 0) {
Expand Down Expand Up @@ -1081,7 +1078,7 @@ sub edSearchBackward {
#

sub Usage {
die "Usage: ed [-p prompt] [-dsv] [file]\n";
die "Usage: ed [-p prompt] [-ds] [file]\n";
}

#
Expand Down Expand Up @@ -1110,7 +1107,7 @@ ed - text editor
=head1 SYNOPSIS
ed [-p prompt] [-dsv] [file]
ed [-p prompt] [-ds] [file]
=head1 DESCRIPTION
Expand Down Expand Up @@ -1164,10 +1161,6 @@ By default no prompt is displayed.
Suppress byte counts
=item -v
Print full error messages; equivalent to the "H" command
=back
=head2 EDITOR COMMANDS
Expand Down

0 comments on commit b140a8e

Please sign in to comment.