Copying code from elsewhere

There are three errors in the following code snippet:

These and other errors are common on the web, but can come from anywhere. Sometimes they are caused by user ignorance and other times by the platform itself. Can you tell what the issues are? In order of their appearance:

  1. The funny–looking horizontal line before color is not a double dash, and not even a single dash, but rather an en dash. WYSIWYG tools often convert double dashes to en dashes automatically. But en dashes are not used to prefix options, so the whole word is going to be treated as a pattern and the rest of the arguments will be treated as paths, leading to a confusing result:

  2. As you can see from the error message above, the quotes around some pattern are not syntactic. That is, instead of marking the start and end of the filename they are treated as part of the filename. That is because they are typographic quotes, another piece of common automatic formatting by WYSIWYG tools. And since there are no syntactic quotes that part of the command is split into words.

  3. The string middle is slanted or italicized, which hints at the problem for anyone familiar with Markdown and similar formats. These formats are sent through a preprocessor program to produce HTML. And a common way to produce italicized text in the resulting HTML is to surround the text with asterisks, which we know as globbing characters!

So the original command was probably something like this:

“Probably” is the best we can do without more information. Although the typographic characters would normally set off alarms they could of course be intentional. And the text which resulted in 𝘮𝘪𝘥𝘥𝘭𝘦 could also be from any other common italicization such as _middle_ or /middle/.


This page is a preview of The newline Guide to Bash Scripting

Start a new discussion. All notification go to the author.