Date: Wed, 20 May 2020 14:45:55 +0200 From: Polytropon <freebsd@edvax.de> To: listac@nebelschwaden.de Cc: freebsd-questions@freebsd.org Subject: Re: Moving sources (base/ports) from /usr Message-ID: <20200520144555.2e935417.freebsd@edvax.de> In-Reply-To: <c7cd6f22-6d6f-9b3a-919e-24972a0f26c1@nebelschwaden.de> References: <8d48921e-7af1-9313-0781-4ba4bd9c1f10@nebelschwaden.de> <ee6f9d59-9ac3-5d1e-baec-405fc1b24ab2@nebelschwaden.de> <20200520110833.f47610a48f0f28dd563c13aa@sohara.org> <2c3bd26c-aaa3-9998-e5e5-e3f4f3796ffc@nebelschwaden.de> <0b98639e-e714-412c-950e-7d20be5d1147@hedeland.org> <c7cd6f22-6d6f-9b3a-919e-24972a0f26c1@nebelschwaden.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 20 May 2020 13:49:19 +0200, Ede Wolf wrote: > Sometimes, being pedantic helps quite a bit: > > ... (fresh login) > # echo $SOURCEDIR > /clutter/src > # env | grep SOURCEDIR > # > # SOURCEDIR="/clutter/src" > # export SOURCEDIR > # env | grep SOURCEDIR > SOURCEDIR=/clutter/src > > Even if this distinction is currently raising more question than it > answers, it at least explains the behaviour. It does. My assumption (and therefore not thinking about this possibility) was that you had set and exported (!) the variable to the environment. The common forms FOO="bar" export FOO and export FOO="bar" are the forms typically found when you want to modify tne environment, and _that_ is what's being passed from one instance of the shell to the next instance (subshell). Regular variables do not get passed that way: $ FOO=bar $ echo $FOO bar $ sh $ echo $FOO $ _ If you use "export" here, you can easily see the difference: $ FOO=bar $ echo $FOO bar $ export FOO $ sh $ echo $FOO bar $ _ The mentioned form $ export FOO=bar would lead to the same effect. Checking with "env" is a good idea if you want to explicitely (!) confirm that a certain variable is set in the environment, not just as a mere shell variable. This doesn't just apply to shell scripts invoked by shell scripts, but also to program that query *envp[], the (optional) third parameter of the standard main() function. > And I know I need to rethink my understanding of shell vs. environment > variables (and the corresponding files). The files can set shell variables and environmental variables. The case for _which_ kind of shell this applies (login shell, interactive shell, scripting shell) depends on the file name, as explained in "man sh", section "Invocation". > Thanks for the heads up, with that in mind I'll reread the comment on > sh(1) and .shrc from before and, well, have a talk with my favourite > search enginge. It's a search engine, not a listening engine. ;-) However, it is not a bad idea to visit fundamental knowledge and shell basics from time to time. It makes life easier, especially for those corner cases where you expect a certain behaviour, but it strangely does not happen. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200520144555.2e935417.freebsd>