Skip to content

Commit b544cf9

Browse files
authored
Capture piped exit codes in scripts and use those for exit codes.
Fixes kdave#128
1 parent beb9e2d commit b544cf9

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

btrfs-balance.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@ case "$BTRFS_LOG_OUTPUT" in
7070
*) cat;;
7171
esac
7272

73-
exit 0
73+
# Capture exit code from the piped command above and return it
74+
EXIT_STATUS=${PIPESTATUS[0]}
75+
exit $EXIT_STATUS

btrfs-defrag.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ case "$BTRFS_LOG_OUTPUT" in
4040
*) cat;;
4141
esac
4242

43-
exit 0
43+
# Capture exit code from the piped command above and return it
44+
EXIT_STATUS=${PIPESTATUS[0]}
45+
exit $EXIT_STATUS

btrfs-scrub.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@ case "$BTRFS_LOG_OUTPUT" in
7070
*) cat;;
7171
esac
7272

73-
exit 0
73+
# Capture exit code from the piped command above and return it
74+
EXIT_STATUS=${PIPESTATUS[0]}
75+
exit $EXIT_STATUS

btrfs-trim.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ case "$BTRFS_LOG_OUTPUT" in
4141
*) cat;;
4242
esac
4343

44-
exit 0
44+
# Capture exit code from the piped command above and return it
45+
EXIT_STATUS=${PIPESTATUS[0]}
46+
exit $EXIT_STATUS

0 commit comments

Comments
 (0)