Hi all,
Ich habe mal eine offtopic Frage bzgl. shell scripting.
Da shell scripting ja ziemlich tolerant bzgl. Fehler ist, finde ich es
eigentlich ganz gut
set -e
set -u
zu benutzen.
Um Programmfehler abzufangen kann ich z.b. so was machen:
my_command || {
rc=$?
echo "Error $rc in my_command"
}
oder um explizit einen potentiellen Fehler zu ignorieren
ok_if_bad_command || true
Soweit so gut.
Wenn ich z.b. dieses
test -f /not_existing
in einem Script habe bricht das Script mit Fehler ab. Wie gewünscht.
Wenn ich aber dieses habe
test -f /not_existing && true
bricht das Script nicht ab, obwohl der && Ausdruch doch false ergibt.
Das verblüfft mich.
Kann das jemand (Olli?) erklären?
-- Manfred To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org with "unsubscribe de-bsd-questions" in the body of the messageReceived on Sat 09 Aug 2014 - 19:36:07 CEST