On 10/12/2013 11:56 AM, Pierre Labastie wrote:
> Le 12/10/2013 18:27, Dan McGhee a écrit :
>> <snip>
>> Here is the line in question:
>>
>> cd "$HOME/xxxbuild/yyysrc" && srcdir="$(pwd)" || exit 1
>>
>> <snip>
>>
>> "Change to the package build directory IF AND ONLY IF the package source
>> directory is the same as the current directory OR exit with a status of 1."
>>
>> In typing this I've also generated a question about the "'s, but it's
>> the use of the logical operators, which I've capitalized, that has my
>> attention. Here's the question:
>>
>> If <&&> and <||> are logical operators, shouldn't the whole command be
>> enclosed in double brackets,
>> [[ command1 && command2 || command3 ]]? The other syntax I know would be
>> [ command1 -a command2 -o command3 ].
>>
>> <snip>
> Well, dunno if this is rant, recommandation or comment, but you should have a
> look
> at the paragraph about "Lists" in the bash manpage.
> It's all explained there, much better than I would.
>
> But now a rough answer: the meaning of this line is:
> change directory to ${HOME}/blah. If that succeeds, set the srcdir variable
> to the
> full path to that directory. If either of the preceding commands fails then
> exit with error code.
>
> Regards
> Pierre
Thanks, Pierre.
I suppose that the most practical thing for me to do is "jump into" Ch.
6 and build with the script in the hint as it exists now. I could
"pause" at the end of this command to see what was happening. However,
in a previous life I was an engineer (Oh, no!!) and my OCD has kicked
in. First of all, I want to understand everything the script is doing
and when I looked at it in my text editor (gedit in Ubuntu) I saw a
problem. With that editor the only valid thing in pick is what's
between two quotes in an <echo> command. Anything else in pink has
something wrong in front of it--a syntax error. In gedit everything in
the script after <"$(pwd)"> is pink. There's something wrong, and I'd
like to find it before I start.
I read the bash man page about Lists. Thanks for pointing that out.
I'm thinking that the syntax I was thinking of was for running tests.
And the plain language translation that you used is very close to my
own. But let's take translation apart list by list and operator by
operator. I'm going to be very pedantic and put in the bash man page
words using what's above rather than command{1,2}.
<srcdir="$(pwd)"> is executed if and only if cd "$HOME/blah" returns an
exit status of zero. (The exit status of <cd "$Home/blah" will always be
zero since all elements of the statement are previously defined in the
script and are not dependent on anything else. It's like <cd ~>.)
Now, <exit 1> will be executed if and only if the exit status of
<srcdir="$(pwd"> is non-zero. And since the exit status of the list
depends on the status of the last command executed it will always be zero.
Therefore, <|| exit 1> becomes irrelevant because of the existence of
$HOME/blah. I don't know if gedit is "smart enough" to pick up errors
in logic or not, but it tells me that something is not right.
The quotation marks, "", also have my attention. I know that different
script writers do things differently. I use them only when syntax
requires it or when talking about an array. Maybe it's me who's
ranting. :)
I'm also thinking in terms of testing and maybe I should just look at
the commands themselves.
Thanks again,
Dan
--
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page