File: bashism_in_examples

package info (click to toggle)
dump 0.4b47-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,316 kB
  • sloc: ansic: 16,267; sh: 5,138; makefile: 161
file content (34 lines) | stat: -rw-r--r-- 871 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Description: fix bashisms in dump_disk example script
 Three conditionals in the examples/dump_on_cd_3/dump_disk are fixed to
 avoid bash-specific syntax.
Author: Chris Lamb <chris@chris-lamb.co.uk>
Reviewed-by: Bdale Garbee <bdale@gag.com>
Bug-Debian: http://bugs.debian.org/489570

--- a/examples/dump_on_cd_3/dump_disk
+++ b/examples/dump_on_cd_3/dump_disk
@@ -38,13 +38,8 @@ cleanup() {
 	rm -f $FIFO
 }
 
-error_exit() {
-	retcode=$?
-	echo >&2 "Error $retcode: exiting"
-	exit $retcode
-}
-
-trap error_exit ERR
+# exit on errors
+set -e
 
 write_output() {
 	# supplied info from "dump -F":
@@ -83,7 +78,7 @@ if [ "$#" = "2" ] && [ -p "$1" ]; then
 	exit 0
 else
 	mkfifo $FIFO
-	trap cleanup EXIT
+	trap cleanup 0
 	if write_output "$FIFO" "0"; then
 		if $DUMP "$@" -F "$0" -f "$FIFO" -B$BSIZE; then
 			echo "Waiting for background writing process to complete"