This extension helps you work with package definition files for
It currently supports only a single type of package repository: the
Arch User Repository (AUR).
PKGBUILD file without this extension
PKGBUILD file with this extension
|ShellCheck findings are mostly irrelevant.
||Only see ShellCheck diagnostics that matter.
The Packaging extension supports user-contributed
PKGBUILD files in the
PKGBUILD files opened in VS Code, this extension enables
linting through the
By default, however, ShellCheck emits a number of unhelpful warnings
that are false alarms in the context of
PKGBUILD files. To remove
those false alarms, this extension configures the ShellCheck
extension in the following ways:
Sets Bash as the shell.
Disables rule SC2034
(“foo appears unused. Verify it or export it.”)
Disables rule SC2154
(“var is referenced but not assigned.”)
Disables rule SC2164
cd ... || exit in case
Will not affect regular shell scripts, only
This extension depends on the
maintained by Felipe Santos.
Usually, VS Code will take care of this dependency for you.
When in doubt, you can reinstall the ShellCheck extension to get the
latest version. You should have to do that only once though, if
Q. Why does this extension set Bash as the shell?
makepkg, the program that sources
PKGBUILDs, runs in Bash.
Q. Why does this extension disable rule SC2164 for
makepkg first configures
shopt -o -s errexit, which is
roughly equivalent to
set -e , before it calls into
PKGBUILD’s functions. ShellCheck doesn’t know this, and
still reports SC2164 violations, but those are unhelpful false
alarms in that context.
Q. Why does this extension disable rule SC2034 for
A. There are
more than a dozen PKGBUILD variables.
SC2034 violations for every single one of
them, because it can’t tell that
makepkg will consume those
variables after it sources the
PKGBUILD. So those are
unhelpful false alarms.
Disabling rule SC2034 incurs some collateral damage, but due to
limitations in ShellCheck itself,
this is probably the best we can do for now.
Q. Why does this extension disable rule SC2154 for
A. Similarly to SC2034, ShellCheck emits
SC2154 violations for
pkgdir, because it can’t tell
makepkg always pre-initializes those variables before it
PKGBUILD functions. Hence, these are false alarms,
Just like SC2034, disabling rule SC2154 will also suppress
some legitimate ShellCheck warnings but we can’t do anything
about it unless someone introduces
the missing feature
to ShellCheck proper.
A shout-out to these amazing people:
Copyright (c) 2022 Claudia Pellegrino
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
For a copy of the License, see LICENSE.