Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

ShellCheck's -x Flag Lets You Source Files without SC1091 Warnings


This is really handy to avoid having to add a source path as a comment or ignore SC1091 every time you source a file.

Quick Jump: Demo Video

I’m a really big fan of ShellCheck. Often times your shell scripts might source in another file. When you call shellcheck -x myscript instead of shellcheck myscript that lets ShellCheck know to check the path of sourced files without explicitly annotating them with a comment.

It will still detect source calls with incorrect paths too because it tests the path by default when using -x. If you don’t use -x chances are you’ve found yourself adding shellcheck specific comments like # shellcheck disable=SC1091 to every file you source.

Demo Video


  • 0:06 – Demonstrating the SC1091 warning and how to fix it
  • 1:06 – Using the -x flag to avoid annotating every time you source a file
  • 1:32 – I might alias shellcheck to always run with -x
  • 2:07 – The -x flag still tests to make sure the sourced file exists

Will using -x make its way into all of your shellcheck commands? Let us know!

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per month (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.