5
1
By default, for many kinds of errors tar
prints a message to stderr and then continues on its way -- the errors it calls "recoverable" errors, typically errors that relate to a single file or archive member, like permissions problems.
Sometimes this behavior is really obnoxious. E.g., if I'm untarring an archive and the disk is full, then I may get something like this:
tar: python-lib/PyML/classifiers/ext/_cgist.so: Wrote only 2048 of 10240 bytes
tar: python-lib/PyML/classifiers/ext/_csmo.so: Cannot write: No space left on device
tar: python-lib/PyML/classifiers/ext/_csvmodel.so: Cannot write: No space left on device
tar: python-lib/PyML/classifiers/ext/_knn.so: Cannot write: No space left on device
tar: python-lib/PyML/classifiers/ext/_libsvm.so: Cannot write: No space left on device
tar: python-lib/PyML/classifiers/ext/_mylibsvm.so: Cannot write: No space left on device
tar: python-lib/PyML/classifiers/ext/cgist.py: Cannot write: No space left on device
tar: python-lib/PyML/classifiers/ext/csmo.py: Cannot write: No space left on device
that can go on for thousands of lines in a big archive. If this happens in a script, I'd much rather tar
just exited promptly so I can give a prompt error to the user.
Is there any way to force tar
to exit on the first error it sees? I don't see it in a scan of tar --help
. Any sane recipe for a wrapper script to accomplish this purpose would also be gratefully accepted.
+1 Nice. Never even heard of
/dev/full
. Useful tip. – trojanfoe – 2012-05-30T08:14:30.100Clever idea, but it doesn't work. At least not with GNU tar 1.22, the version I have on hand. Stracing the
tar
process confirms that it cheerfully continues on after each write to standard error fails.Have you actually tried this idea? What version of
tar
? – Greg Price – 2012-05-30T21:44:23.570I tried with other applications.
tar
probably just ignores the error. There need to be a pipe so thatSIGPIPE
is sent totar
in case of error to knock it off. – Maxim Egorushkin – 2012-05-31T08:08:05.167