logo

Should you use emoji in shell scripts?

A few things to consider

Joel Clermont
Joel Clermont
2025-10-02

When I'm writing these tips, I'll sometimes insert ??? for a link or piece of metadata I'm not quite ready to fill in yet. Occasionally, I would forget to come back to it, and Aaron would catch it during his review.

To avoid this, I built a simple one-line shell script that searches through my content files for any occurrences of ??? as part of our composer ci script.

! find content -name '*.md' -exec grep -l -i '???' {} + 2>/dev/null || \
  (echo '❌ Found \"???\" in markdown files. Please complete all content before committing.' && exit 1)

I run this locally before committing, and it runs again automatically in CI when I push up the branch.

The script works, and it has saved me more than once from an embarrassing PR review, but on a recent pull request, I noticed the emoji was replaced with the Unicode escape sequence \u274c.

Why the change?

Well, even though the emoji did work fine on my local machine, there are potential cross-platform compatibility issues with using emoji in shell scripts.

For example, if someone were to run the script in a terminal that doesn't support Unicode or emoji characters, they might see garbled text or question marks instead of the intended emoji.

There could also be issues if the file was ever saved with a different encoding that doesn't support those characters, or if the target machine (or container) didn't have proper font support.

It was a small defensive change, but it improved the portability of the script.

Here to help,

Joel

P.S. Wish you had a couple Laravel experts to review your code? Let's discuss how we can help.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.