DEV Community

David Muckle
David Muckle

Posted on


A Fun Little Bug

Today I ran into a fun little bug while debugging the shell I've been working on, while also using my VT420.

My terminal has been weird for a while, and will sometimes fail to backspace on things such as password inputs. In this case, with my shell, it would print ^H instead of actually deleting a character.

So, what happens if you run ls -l foo ^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H?

You get the wonderful : No such file or directory. But it should be listing the contents of foo. What's going on?

From this, we can infer some code in ls.

printf("%s: cannot access %s: No such file or directory\n", command, filename);
Enter fullscreen mode Exit fullscreen mode

As we can see, because the filename string has backspace characters in it, C will print it out, including the backspace characters, thus deleting the printing about the command being run and the filename.

Thankfully, this wasn't an issue with my shell, but rather my terminal. Changing firmware settings for the backspace key fixed things, including backspacing on password input.

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git