Bring in some small changes from LibreOffice:

Handle NetBSD like the other BSDs in more cases.- Thomas Klausner
Add DragonFly defines. 				- Francois Tigeot
distinguish exit due failure vs signal aborted	- Caolan McNamara
free after use					- David Tardon
dir is always copied--free unconditionally	- David Tardon
Output the "Executing shell macro" only with -vr- Tor Lillqvist
don't let our fprintf pollute errno		- Michael Meeks
workaround bashism