On 05/11/2011 04:18 PM, 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. >
The problem is that you misunderstand the syntax. When a conditional such as '&&' is used, none of the commands are interpreted by bash until there are no conditionals. Here is a simple example similar to the sudo instructions: cat > file << "EOF" && # begin file put some stuff here # end file EOF chmod 644 file Here is a _logical_ breakdown of how the commands are interpreted. It is bash that interprets '> file << "EOF"', not cat. Bash waits for EOF and puts everything else in a queue, when it receives EOF, it then interprets the && (cat is not executed yet), and it waits for the next command. If you break at this point, bash is interrupted and the cat command is not executed. chmod is the next command that bash interprets and it ends the queue as there is no conditional at the end. In the case of the sudo commands, you must enter both cat and chmod before bash actually executes anything. In the case of xinetd's instructions, there are 22 commands that have to be entered into the queue before any work is done. Do not take the above text as a _technical_ explanation, as the order of events has been greatly simplified for example purposes. -- DJ Lucas -- http://linuxfromscratch.org/mailman/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
