You are not logged in.
Hi!
I wanted to know whether one should use `${pkgname}` or `$pkgname`, or is it just a preference.
Though which would be more ideal? I think the former? I think using it improves readability, but overusing it makes the PKGBUILD overall more bloated.
What are your thoughts?
Thanks!
Last edited by LinuxLover471 (2026-03-23 04:05:53)
--- asyync1024
Offline
I guess, $pkgname for the sake of cleanliness, use ${pkgname} when you’re appending strings directly to the variable where it might get confusing...
No need to over-engineer it! ![]()
-----------
Offline
There are situations where $variable might cause side effects like concatenating with other letters
At the opposite, using ${variable} you don't have such effects, therefore you don't have to worry about how you use your variables
For me there is only ${variable} because security beats uncertainty
Offline
There are situations where $variable might cause side effects like concatenating with other letters
Can you please elaborate on what can be the side effects? I would love to know how big of a problem can such a small change cause.
Thanks!
--- asyync1024
Offline
If you have your variable $var and you want to concatenate this with another string:
var="asdf"
echo "$vartest" # <-- breaks
echo "${var}test"This example is obvious but you might have addititional information which might be confusing to the reader:
var="asdf"
echo "$var-v2"As a bash-enthusiast, you know that the hyphen will be used literally, but it might lead to confusion. Is it the variable "var-v2" or not?
If you want to act on the content in bash, you must use the curly braces. For example, lowercase a string with "${var,,}". Using it everywhere will give it consistency.
Offline
Thanks to all of you for your respective insights!
I have decided to use ${var} only when using url's as they generally are quite hard to read, others aren't that hard.
Overusing ${var} can make a PKGBUILD bloated.
I have marked this post as SOLVED.
Last edited by LinuxLover471 (2026-03-29 07:17:08)
--- asyync1024
Offline