On 05/12/2011 04:26 PM, Pol Vangheluwe wrote:
> Op 12-mei-2011, om 11:34 heeft Simon Geard het volgende geschreven:
>
>> On Wed, 2011-05-11 at 23:18 +0200, Pol Vangheluwe wrote:
>>
>>> The bash manual tells me that the structure "command1&&  command2"
>>> executes command2
>>> if and only if command1 returns the exit status of zero.
>>> But here, there is only one command (cat), so I really don't
>>> understand why "&&" is needed.
>>
>> Correct on the syntax, but you're wrong that only one command is
>> present. From the sudo example:
>>
>> cat>  /etc/pam.d/sudo<<  "EOF"&&
>> # Begin /etc/pam.d/sudo
>> ...content removed...
>> # End /etc/pam.d/sudo
>> EOF
>> chmod 644 /etc/pam.d/sudo
>>
>>
>> There are two commands - the 'cat', and the subsequent 'chmod'. The
>> xinetd examples are similar.
>>
>>
>>> BTW: can you explain why the 'xinetd.conf' script has no "&&" but the
>>> 'xinetd.d/<server>' scripts have it on the xinetd-2.3.14 page?
>>> The first runs well, the other fail...
>>
>> Because the xinetd.conf script is a single command, just one 'cat'
>> statement. But the xinetd.d case consists of twenty or so commands, all
>> separated by&&.
>>
>> Simon.
>
> OK, I understand…
>
> My problem was caused by the fact that I made a (one-by-one) selection of the 
> 22 cat commands
> for the servers I wanted to use.  If you copy the content of the grey 
> rectangle as a whole
> then there is no problem.
>
> However, I think that the script is also working without the "&&" operators.
> You only loose the conditional dependency from one cat command to the next 
> one.
> In other words: the script with "&&" stops when a cat command fails but 
> continues with the next cat command without the"&&"?

Correct. The purpose of using the && syntax is that if anything errors, 
the commands will not continue past the error, which gives you a much 
better chance to catch the offending command.

-- DJ Lucas


-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to