mirror of
https://github.com/Phantop/dotfiles
synced 2024-11-26 08:43:19 +00:00
zzexe: file extensions and preservation
This commit is contained in:
parent
2a456a5b7f
commit
fb7657d22f
13
bin/zzexe
13
bin/zzexe
|
@ -10,22 +10,23 @@ else
|
||||||
prefix="$1 "
|
prefix="$1 "
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
cat > "$1"~ << 'EOF'
|
|
||||||
#!/bin/sh
|
echo '#!/bin/sh' > "$1"~
|
||||||
|
echo out=\`mktemp -t .zzXXXX."${1##*.}"\` >> "$1"~
|
||||||
|
cat >> "$1"~ << 'EOF'
|
||||||
dir=`dirname "$0"`
|
dir=`dirname "$0"`
|
||||||
out=`mktemp -t .zzXXXX`
|
|
||||||
tail -n +11 "$0" | zstd -cd > "$out"
|
tail -n +11 "$0" | zstd -cd > "$out"
|
||||||
chmod +x "$out"
|
chmod +x "$out"
|
||||||
ln -s "$out" "$dir"
|
ln -s "$out" "$dir"
|
||||||
trap "res=$?" 0 1 2 3 5 10 13 15
|
trap "res=$?" 0 1 2 3 5 10 13 15
|
||||||
EOF
|
EOF
|
||||||
echo $prefix'$dir/`basename $out` $@' >> "$1"~
|
echo "$prefix"'$dir/`basename $out` $@' >> "$1"~
|
||||||
cat >> "$1"~ << 'EOF'
|
cat >> "$1"~ << 'EOF'
|
||||||
rm "$out" "$dir"/`basename $out`
|
rm "$out" "$dir"/`basename $out`
|
||||||
exit $res
|
exit $res
|
||||||
EOF
|
EOF
|
||||||
zstd --ultra -22 "$1"
|
|
||||||
rm "$1"
|
zstd --ultra -22 "$1" &&
|
||||||
cat "$1"~ "$1".zst > "$1"
|
cat "$1"~ "$1".zst > "$1"
|
||||||
rm "$1".zst "$1~"
|
rm "$1".zst "$1~"
|
||||||
chmod +x "$1"
|
chmod +x "$1"
|
||||||
|
|
Loading…
Reference in a new issue