Skip to content

martinwguy/lua-ed

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
ed
 
 
 
 
 
 
 
 
 
 
This is a version of the standard Unix editor "ed", implemented in Lua.

It was written by translating the sources of GNU ed 1.5 into Lua, but using
the Lua search-and-replace patterns instead of standard regex.

CHANGES

- Patterns for search and replace are Lua 5.1 patterns (as used in string.gsub)
  which has different syntax for matching and replacing, including:
  - s/foo/bar/3 replaces the first three occurrences of foo instead of the
    third because that is how the Lua "snum" parameter works.
  However, the replacement pattern "%" (the same as the previous substitution)
  is recognized.
- The contents of the yank buffer remain intact when editing a different file
  so you can yank lines from one file and put them into another.
- The 'l' command lists control characters as \nnn in decimal, not octal
  (to follow the Lua convention).
- The 'P' command can be followed by an optional parameter after a space to set
  the prompt string.  Trailing spaces are recognized and preserved. e.g.:
  P >>> 
- Prompt and error message printing are on by default.

BUGS

- Shell escapes and piping are not implemented
- The pattern cannot contain the search pattern delimiter,
  which should be able to occur inside character ranges "/[/]/
  or if quoted as "\/" (or maybe "%/").
- Unbalanced square brackets in patterns are not an error here.
  (e.g. testsuite s10 succeeds when it should fail)
- There are some rare cases (bugs) when an error value (nil) is returned from
  below without having printed (or set) an error message.
  In these cases we print "Something went wrong". This should never happen...
- NUL characters in files are not handled.  They have the effect of truncating
  the line at that character.  This is due to the Lua 5.1 string library
  failing to handle NULs (and is fixed in Lua 5.2 but untested here).

It passes the GNU ed 1.5 test suite, modulo scripts that use shell escapes
and modulo the different regular expression syntax.
In the copy of "testsuite" here, the regex syntax for runnable tests has been
modified to use the Lua syntax.

Enjoy

   Martin Guy <martinwguy@gmail.com>, March 2011

About

An implementation of the standard Unix editor "ed", written in Lua

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published