aureliojargas / sedsed

Debugger and code formatter for sed scripts
https://aurelio.net/projects/sedsed/
GNU General Public License v3.0
115 stars 10 forks source link

Detect and show error on incomplete s and y commands #48

Closed aureliojargas closed 5 years ago

aureliojargas commented 5 years ago

For example, a single s breaks the parser:

$ ./sedsed.py s
Traceback (most recent call last):
  File "./sedsed.py", line 1367, in <module>
    cmd = SedCommand(possiblecmd)
  File "./sedsed.py", line 642, in __init__
    self.do_it_all()
  File "./sedsed.py", line 699, in do_it_all
    self.delimiter = self.junk[0]
IndexError: string index out of range

On the other hand, other forms of incomplete s commands go undetected:

$ ./sedsed.py s/

$ ./sedsed.py s/foo

$ ./sedsed.py s/foo/

$ ./sedsed.py s/foo/bar

$

The same applies for incomplete y commands.

aureliojargas commented 5 years ago

Fixed by the new sedparse parser, see #52.

$ ./sedsed.py s
ERROR: sedparse: -e expression #1, char 2: unterminated `s' command
$ ./sedsed.py s/
ERROR: sedparse: -e expression #1, char 2: unterminated `s' command
$ ./sedsed.py s/foo
ERROR: sedparse: -e expression #1, char 5: unterminated `s' command
$ ./sedsed.py s/foo/
ERROR: sedparse: -e expression #1, char 6: unterminated `s' command
$ ./sedsed.py s/foo/bar
ERROR: sedparse: -e expression #1, char 9: unterminated `s' command
$