[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
abs-guide - Example 11-17. while loop with multiple conditions
From: |
Herbert Parentes Fortes Neto |
Subject: |
abs-guide - Example 11-17. while loop with multiple conditions |
Date: |
Tue, 21 Oct 2014 14:26:17 -0200 |
Olá,
estou lendo o abs-guide e lá tem o seguinte exemplo:
------------------------------------------------------
#!/bin/bash
var1=unset
previous=$var1
while echo "previous-variable = $previous"
echo
previous=$var1
[ "$var1" != end ] # Keeps track of what $var1 was previously.
# Four conditions on *while*, but only the final one controls loop.
# The *last* exit status is the one that counts.
do
echo "Input variable #1 (end to exit) "
read var1
echo "variable #1 = $var1"
done
# Try to figure out how this all works.
# It's a wee bit tricky.
exit 0
-------------------------------------------------------
o while tem 4 condições, mas como o comentário diz apenas o último
'exit status' é o que conta. Pergunta o por quê.
É pelo mesmo motivo que o último comando de um script é o que vale
como 'exit status'?
obrigado,
--
Herbert Parentes Fortes Neto (hpfn)
- abs-guide - Example 11-17. while loop with multiple conditions,
Herbert Parentes Fortes Neto <=