proggi1 | proggi2 || echo "error"
Frage: Wie werden die exit codes der pipe ausgewertet? Addition?
Danke,
Samsara
(smoking on his bash pipe)
proggi1 | proggi2 || echo "error"
Frage: Wie werden die exit codes der pipe ausgewertet? Addition?
Danke,
Samsara
(smoking on his bash pipe)
Interface design
whohas - wer hat's im Repository? Debian? Fedora? Gentoo? ...?
Hardware compatibility list - das Original mit bereits 3000 Einträgen
It ain't a hack if it ain't dirty.
offenbar den error-code des letzten Programms:
http://www.mail-archive.com/linux-us.../msg14697.htmlFor foreground pipes, it's impossible to get the exit code of any but
the last pipe (bad design). I'd also really like to know how to get the
exit codes of all of the earlier commands in the pipeline - otherwise
safe programming is not possible: an earlier command might make the sky
crash down, and bash happily reports "success" at the end of the
pipeline (doh, tcsh gets this right).
Wers nicht glaubt (wie ich) kannst leicht selber ausprobieren. Als root ( April April - nein, natürlich als normaler User! sonst gehts arg ins Auge)
ersteres sagt "errorli" - weil "rm -Rf /root" fehlschlug, letzteres sagt nichts - der Output vom Kommando ist natürlich trotzdem zu sehen, weil nur der STDOUT weitergepiped wurde, der STDERR gelangt trotzdem auf die Konsole - aber "errorli" wird nicht ausgegeben.Code:cd ls | rm -Rf /root || echo "errorli" rm -Rf /root | ls || echo "errorli"
Bedenklich.
MfG Peschmä
The greatest trick the Devil ever pulled was convincing the world he didn't exist. -- The Usual Suspects (1995)
Hey, I feel their pain. It's irritating as hell when people act like they have rights. The great old one (2006)
Workaround: erst in eine Datei umleiten, dann wieder auslesen, z.B.
Macht leider alles etwas langsamerCode:ls *.jpg > suchfile.txt || echo "errorli" grep portrait < suchfile.txt || echo "errorli"
Gruss,
Samsara
Interface design
whohas - wer hat's im Repository? Debian? Fedora? Gentoo? ...?
Hardware compatibility list - das Original mit bereits 3000 Einträgen
It ain't a hack if it ain't dirty.
Ja, irgend ne wirklich schlaue Alternative fällt mir auch nicht ein.
Aber damit geht natürlich auch sonst noch das Verhalten der Pipe verloren (es command2 fängt schon an bevor command1 beendet wurde)
MfG Peschmä
The greatest trick the Devil ever pulled was convincing the world he didn't exist. -- The Usual Suspects (1995)
Hey, I feel their pain. It's irritating as hell when people act like they have rights. The great old one (2006)
Ich bin mir nicht sicher, ob ich Dich richtig verstanden habe, aber in einem BefehlOriginal geschrieben von peschmae
Aber damit geht natürlich auch sonst noch das Verhalten der Pipe verloren (es command2 fängt schon an bevor command1 beendet wurde)
wird afaik das zweite Kommando erst ausgefuehrt, nachdem das erste seinen exit status bekannt gegeben hat. Ebenso, wenn man die Kommandos auf zwei Zeilen in einem Skript ausfuehrt. Das gilt zumindest, solange man das erste Kommando nicht im Hintergrund ausfuehrt!Code:command1; command2
Gruss,
Samsara
Interface design
whohas - wer hat's im Repository? Debian? Fedora? Gentoo? ...?
Hardware compatibility list - das Original mit bereits 3000 Einträgen
It ain't a hack if it ain't dirty.
... ja
aber mit Pipe ist das nicht so.
z.B. was ich oft brauche:
mkisofs -J -r ~ | cdrecord -dev=0,0,0 -speed=2 -eject -
da fängt cdrecord schon mal an, bevor mkisofs fertig ist. Und das Verhalten kriegst du nicht mehr hin, wenn du - weil du z.B. den exit-Status von mkisofs brauchst - das ganze so machst:
mkisofs -J -R ~ -o /tmp/tmp.iso && cdrecord -dev=0,0,0 -speed=2 -eject /tmp/tmp.iso
MfG Peschmä
The greatest trick the Devil ever pulled was convincing the world he didn't exist. -- The Usual Suspects (1995)
Hey, I feel their pain. It's irritating as hell when people act like they have rights. The great old one (2006)
Okay, verstanden
Samsara
Interface design
whohas - wer hat's im Repository? Debian? Fedora? Gentoo? ...?
Hardware compatibility list - das Original mit bereits 3000 Einträgen
It ain't a hack if it ain't dirty.
Lesezeichen