summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtools/shmin.sh22
1 files changed, 12 insertions, 10 deletions
diff --git a/tools/shmin.sh b/tools/shmin.sh
index d6f35ea..73df7aa 100755
--- a/tools/shmin.sh
+++ b/tools/shmin.sh
@@ -213,16 +213,18 @@ minify()
fi
# Write the output.
- if ! printf '%s\n' "${buffer}" >"${output}~"; then
- die 'Cannot write file "%s"' "${output}~"
- fi
-
- # Set output file name.
- if ! cat "${output}~" >"${output}"; then
- die 'Cannot rename file to "%s"' "${output}"
- fi
- if ! rm "${output}~"; then
- die 'Cannot remove file "%s"' "${output}~"
+ if [ "x${output}" = 'x-' ]; then
+ printf '%s\n' "${buffer}"
+ else
+ if ! printf '%s\n' "${buffer}" >"${output}~"; then
+ die 'Cannot write file "%s"' "${output}~"
+ fi
+ if ! cat "${output}~" >"${output}"; then
+ die 'Cannot rename file to "%s"' "${output}"
+ fi
+ if ! rm "${output}~"; then
+ die 'Cannot remove file "%s"' "${output}~"
+ fi
fi
}