FYI: This is a really quick tip.

Sometimes things break because of random characters, like '. Those kinds of characters may break, for example, shellcheck and other tools based on hlint:

hGetContents: invalid argument (invalid byte sequence)

Also, who likes those stupid chars? Nobody does!

Fixing that

The first step is to find them. I had some of them in my dotfiles project, as you can see in this pull request.

So, using grep, I created the nonascii function:

#!/bin/bash
nonascii() {
 LANG=C grep --color=always '[^ -~]\+';
}

The usage is simple:

$ cat osx/set-defaults.sh | nonascii
# Don't animate opening applications from the Dock
# Don't prompt for confirmation before downloading
# Add the keyboard shortcut ⌘ + Enter to send an email in Mail.app
# Disable smart quotes as it's annoying for messages that contain code
# Don't automatically rearrange Spaces based on most recent use
# Disable smart quotes and smart dashes as they're annoying when typing code
# Disable the "Are you sure you want to open this application?" dialog
# Remove duplicates in the "Open With" menu

it won’t be shown here, but all nonascii chars are in red.

Fix it now is straightforward, but, without this list, it would take a big amount of time to read the entire file paying attention to this kind of detail.