This extension helps you work with package definition files for package repositories.
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. |
customizepkg patch file with syntax highlighting |
|---|
![]() |
The Packaging extension supports user-contributed PKGBUILD files in the AUR.
For PKGBUILD files opened in VS Code, this extension enables
linting through the
ShellCheck
extension.
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 (“Use
cd ... || exitin casecdfails.”) -
Will not affect regular shell scripts, only
PKGBUILDs
The Packaging extension adds syntax highlighting to Pacman *.install
files.
It also sets Bash as the shell, removing an unnecessary Shellcheck warning.
The Packaging extension provides syntax highlighting for
customizepkg-gitAUR
patch files.
For details and examples about customizepkg, see
customizepkg on GitHub.
This extension depends on the ShellCheck extension, 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 ever.
-
Q. Why does this extension set Bash as the shell?
A.makepkg, the program that sourcesPKGBUILDs, runs in Bash.
The same goes for Pacman*.installfiles. -
Q. Why does this extension disable rule SC2164 for
PKGBUILDs?
A.makepkgfirst configuresshopt -o -s errexit, which is roughly equivalent toset -e, before it calls intoPKGBUILD’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
PKGBUILDs?
A. There are more than a dozen PKGBUILD variables. ShellCheck emitsSC2034violations for every single one of them, because it can’t tell thatmakepkgwill consume those variables after it sources thePKGBUILD. 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
PKGBUILDs?
A. Similarly to SC2034, ShellCheck emitsSC2154violations for variables likesrcdirandpkgdir, because it can’t tell thatmakepkgalways pre-initializes those variables before it calls intoPKGBUILDfunctions. Hence, these are false alarms, too.
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:
-
Felipe Santos, maintainer of the VS Code extension for ShellCheck
-
Mark Skelton, author of yarn-plugin-outdated
-
Vidar Holen, who wrote ShellCheck
Copyright (c) 2022–2024 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.txt.


