···11-{ nsxiv, writers }:
22-33-writers.writeDashBin "sxiv" ''
44- set -efu
55- tmpfile="''${TMPDIR:-/tmp}/nsxiv_pipe_$$"
66- trap 'rm -f -- $tmpfile' EXIT
77-88- if [ "$#" -eq 0 ]; then
99- if [ -t 0 ]; then
1010- echo "sxiv: No arguments provided" >&2; exit 1
1111- else
1212- # Consume stdin and put it in the temporal file
1313- cat > "$tmpfile"
1414- fi
1515- fi
1616-1717- for arg in "$@"; do
1818- # if it's a pipe then drain it to $tmpfile
1919- [ -p "$arg" ] && cat "$arg" > "$tmpfile"
2020- done
2121-2222- if [ -s "$tmpfile" ]; then
2323- ${nsxiv}/bin/nsxiv -q "$@" "$tmpfile" # -q to silence warnings
2424- else
2525- ${nsxiv}/bin/nsxiv "$@" # fallback
2626- fi
2727-''
···11+{ nsxiv, writers }:
22+33+writers.writeDashBin "sxiv" ''
44+ set -efu
55+ tmpfile="''${TMPDIR:-/tmp}/nsxiv_pipe_$$"
66+ trap 'rm -f -- $tmpfile' EXIT
77+88+ if [ "$#" -eq 0 ]; then
99+ if [ -t 0 ]; then
1010+ echo "sxiv: No arguments provided" >&2; exit 1
1111+ else
1212+ # Consume stdin and put it in the temporal file
1313+ cat > "$tmpfile"
1414+ fi
1515+ fi
1616+1717+ for arg in "$@"; do
1818+ # if it's a pipe then drain it to $tmpfile
1919+ [ -p "$arg" ] && cat "$arg" > "$tmpfile"
2020+ done
2121+2222+ if [ -s "$tmpfile" ]; then
2323+ ${nsxiv}/bin/nsxiv -q "$@" "$tmpfile" # -q to silence warnings
2424+ else
2525+ ${nsxiv}/bin/nsxiv "$@" # fallback
2626+ fi
2727+''