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 ... || exit
in casecd
fails.”) -
Will not affect regular shell scripts, only
PKGBUILD
s
The Packaging extension provides syntax highlighting for
customizepkg-git
AUR
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 sourcesPKGBUILD
s, runs in Bash. -
Q. Why does this extension disable rule SC2164 for
PKGBUILD
s?
A.makepkg
first 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
PKGBUILD
s?
A. There are more than a dozen PKGBUILD variables. ShellCheck emitsSC2034
violations for every single one of them, because it can’t tell thatmakepkg
will 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
PKGBUILD
s?
A. Similarly to SC2034, ShellCheck emitsSC2154
violations for variables likesrcdir
andpkgdir
, because it can’t tell thatmakepkg
always pre-initializes those variables before it calls intoPKGBUILD
functions. 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 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.