On May 9, 2017 7:02 PM, "John Luke Gibson" eaterjolly@gmail.com wrote:
Like, the first file initiated by the main make file is support/setlocalversion which looks to just check a whole bunch of un-special variables which weren't set in the make script and had no opportunity to be set by any other files I know of (on my system the variables show as empty not having run anything from buildroot, but I can't imagine head would be set to such a specific git command on accident as the one it checks for). Then the if one of the conditions were some how filled, then all it does is print weird strings like this:
printf '%s%s' -g $head
Like this is the if statement:
if head=`git rev-parse --verify --short HEAD 2>/dev/null`
That "=" is assignment, and those "`"s are output substitution. It tries executing that git command, storing the output in the shell variable head. If git succeeds (returns zero), the then clause is executed; if git fails (returns non-zero), the else clause (if present) is executed.
Mind you all this is printed to a variable in the make script called BR2_Version_Full which does nothing in the make script but get printed if a person asks the version, the script calls target-finalize or legal-info-prepare (which it looks like it does unconditionally in both cases). Like am I really that deep in over my head
Apparently, but that's how we learn, right? :)
or does this script really have a bug where if someone sets head to some weird obscure git command it prints that very command in it's legal info?
No.
Like how does that happen that way on accident? It looks like it might serve some obscure purpose if it ran the command (which from I can tell with bash, setting some $(shell x) might do that,
"$(foo)" and "`foo`" are essentially the same. They both run foo, and substitute the output.