If you do much Linux shell scripting, you've probably encountered sed
— the stream editor — in an example. Maybe you've even used it yourself. If all you want to do is substitute text, it is easy and efficient. But if you try to do really elaborate editing, it is often difficult to get things right. The syntax is cryptic and the documentation is lacking. But thanks to [SoptikHa2] you can now debug sed scripts with a text-based GUI debugger. Seriously.
According to the author, the program has several notable features:
- Preview variable values, both of them!
- See how will a substitute command affect pattern space before it runs
- Step through
sed
script – both forward and backward! - Place breakpoints and examine program state
- Hot reload and see what changes as you edit source code
- Its name is a palindrome
There's only one word for that last feature: wow.
Honestly, we are more likely to reach for awk
or Perl if we have heavy lifting, but we know that's a lot of overhead for many tasks. Being able to see what's really happening inside sed
might make us a little less reticent to do things with sed
in the future.
The code is in Rust and it uses a debugging interface that has always been in sed
. Who knew? If you want more details, the author has a blog post about the program that goes into a bit of detail. The built-in debugging interface gives you a lot of internal state information but omits one thing: the command that is executing. So the debugger has to simulate part of sed
to keep track of what statement is executing.
If you need debugging on the rest of your script, relax. Or, try avoiding the bugs in the first place.
via https://ift.tt/358PHB2
No comments:
Post a Comment