From fb7657d22f00bc0e7ad0d1b4d53f4bc8ec538b72 Mon Sep 17 00:00:00 2001 From: Phantop Date: Thu, 20 Jan 2022 16:05:36 -0500 Subject: [PATCH] zzexe: file extensions and preservation --- bin/zzexe | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/zzexe b/bin/zzexe index 4840a6a..ebb99a1 100755 --- a/bin/zzexe +++ b/bin/zzexe @@ -10,22 +10,23 @@ else prefix="$1 " shift fi - cat > "$1"~ << 'EOF' -#!/bin/sh + +echo '#!/bin/sh' > "$1"~ +echo out=\`mktemp -t .zzXXXX."${1##*.}"\` >> "$1"~ + cat >> "$1"~ << 'EOF' dir=`dirname "$0"` -out=`mktemp -t .zzXXXX` tail -n +11 "$0" | zstd -cd > "$out" chmod +x "$out" ln -s "$out" "$dir" trap "res=$?" 0 1 2 3 5 10 13 15 EOF - echo $prefix'$dir/`basename $out` $@' >> "$1"~ + echo "$prefix"'$dir/`basename $out` $@' >> "$1"~ cat >> "$1"~ << 'EOF' rm "$out" "$dir"/`basename $out` exit $res EOF - zstd --ultra -22 "$1" - rm "$1" + + zstd --ultra -22 "$1" && cat "$1"~ "$1".zst > "$1" rm "$1".zst "$1~" chmod +x "$1"