Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jan 2019 13:06:58 -0800 (PST)
From:      "Rodney W. Grimes" <freebsd@pdx.rh.CN85.dnsmgr.net>
To:        Enji Cooper <yaneurabeya@gmail.com>
Cc:        Warner Losh <imp@bsdimp.com>, Devin Teske <dteske@freebsd.org>, "Rodney W. Grimes" <rgrimes@freebsd.org>, Lars Engels <lme@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r342945 - in head: tools/build/mk usr.sbin/bluetooth usr.sbin/bluetooth/bluetooth-config
Message-ID:  <201901112106.x0BL6wAd023063@pdx.rh.CN85.dnsmgr.net>
In-Reply-To: <A5D749B2-580D-403A-9305-697D31ED2190@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> > On Jan 11, 2019, at 12:36 PM, Warner Losh <imp@bsdimp.com> wrote:
> 
> ...
> 
> > I talked about this at BSDCan in June. $foo is preferred (there
> > *is* a difference) and, as you say, if a file is consistently ${foo}
> > then it is fine.
> > 
> > I prefer {} because $foo:bar doesn't work while ${foo}:bar does.

Actually I think $foo:bar works...

But what does not work is when you want to glue foo to something
without intervening special characters.
# foo=FOO
# echo $foobar

# echo ${foo}bar
FOObar
# echo $foo:bar
FOO:bar

> 
> I think the form Warner brings up makes more sense to sh(1) newcomers who might not know the intricacies of the grammar. Similar rules apply to perl and other languages as well when it comes to variable expansion and such.
> Thank you,
> -Enji

I personally do prefer the ${foo} form as iirc it always works
and you dont have to remeber the special rules, where as the other
form does not always work and you end up using the {} form to
fix when it does not, this leading to files with mixed form,
which, imho, is ok, but messy.

It also makes it easy to search and sed for variables and not
get things you didnt want due to common root names in variables.
I can easily explicity find variable ${foo} very easy and not
have to stop at all the ${foobar} variables.

I do understand that for many people the {} are unneeded noise characters.
-- 
Rod Grimes                                                 rgrimes@freebsd.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901112106.x0BL6wAd023063>