]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
src/bin/pdfman: Pipe to read(1) with lastpipe
authorAlejandro Colomar <alx@kernel.org>
Sun, 3 Nov 2024 12:40:36 +0000 (13:40 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sun, 3 Nov 2024 12:40:39 +0000 (13:40 +0100)
This is more readable than nested command substitution.  We already
require bash(1) for ${!#}, so we can abuse it a little bit more.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/bin/pdfman

index edc3d1b93258988171fe04962d54da90bc0e200e..0386b8efd8200439f23b297d9a596e538cb9d871 100755 (executable)
@@ -4,8 +4,12 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 
 set -Eeuo pipefail;
+shopt -s lastpipe;
 
-tmp="$(mktemp -t "$(printf '%s\n' "${!#}" | sed 's,.*/,,').XXXXXX")";
+printf '%s\n' "${!#}.XXXXXX" \
+| sed 's,.*/,,' \
+| xargs mktemp -t \
+| read -r tmp;
 
 man -Tpdf "$@" >"$tmp";
 xdg-open "$tmp";