Why are my shell commands not working as expected?

When I enter or copy-paste commands into the shell or my scripts, I get unusual errors instead of the expected results. What is happening and what can be done about it?

There are a number of possible causes for shell commands not working as expected.

  • Ensure that you are in the expected environment and on the expected system. For example, make sure you are using Cheaha, cloud.rc, your local machine, etc., as appropriate.
  • Ensure that you have all required modules loaded or environment variables set.
  • Be very careful when copy-pasting commands from rich-text sources. Some sources can have invisible and special formatting characters that can corrupt the pasted command. Be sure to use plain-text editors like Notepad++ or VSCode, instead of rich-text editors, when storing commands for future use.
    • Examples of special formatting characters include
      • Start and end quotes (U+201C and U+201D) that are inserted automatically in e.g. Microsoft Word, PDFs and some website prose.
      • Zero-width space (U+200B) used occasionally in PDF documents for formatting reasons
      • No break space (U+00A0) used in PDF and Microsoft Office
    • Examples of rich-text sources (avoid these):
      • Websites and HTML
      • Microsoft Word, Excel, PowerPoint, etc.
      • PDF documents
    • Examples of plaintext editors (use these):
      • VSCode
      • Notepad++
      • Integrated development environments (IDEs) like Visual Studio, CodeBlocks, Eclipse, Spyder, etc.