From 3946ad5f53f8f474107870a5592c53b0b42bfe9a Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 30 Oct 2015 20:33:40 -0400 Subject: tools/shmin.sh: Support writing to stdout --- 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 } -- cgit v0.9.1