diff --git a/bin/ed b/bin/ed index bfdf1e5a..d82af9e5 100755 --- a/bin/ed +++ b/bin/ed @@ -143,9 +143,6 @@ my @ESC = ( ); my %WANT_FILE = ( - 'e' => 1, - 'E' => 1, - 'f' => 1, 'r' => 1, 'w' => 1, 'W' => 1, @@ -568,12 +565,9 @@ sub edFilename { edWarn(E_ADDREXT); return; } - if (defined($args[0])) { $RememberedFilename = $args[0]; - return; } - if (defined($RememberedFilename)) { print "$RememberedFilename\n"; } @@ -909,7 +903,7 @@ sub edParse { $_ = $found . 'p'; return edParse(); } - if (s/\A(g|v)\///) { + if (s/\A([gv])\///) { my $invert = $1 eq 'v'; my $end = rindex $_, '/'; return 0 if $end == -1; # g/re/p needs trailing / @@ -926,6 +920,18 @@ sub edParse { $command = 'nop'; return 1; } + if (s/\A([Eef])//) { # 0-address file commands + $command = $1; + return 0 if m/\A\S/; # space before optional argument + s/\A\s+//; + $args[0] = $_ if length; + return 1; + } + if (s/\A([HhPQq])//) { # 0-address flag commands + $command = $1; + return 0 if m/\S/; # no argument + return 1; + } my @fields = (/^( @@ -941,7 +947,7 @@ sub edParse { (([+-])?(\d+))? # [+]num | -num (([\+]+)|([-^]+))? # + | - )? - ([acdeEfhHijlmnpPqQrstwW=\!])? # command char + ([acdijlmnprstwW=\!])? # command char ([a-z])? # command suffix (\s*)(.+)? # argument (filename, etc.) )$/x);