mirror of
https://github.com/Phantop/dotfiles
synced 2024-11-30 02:22:56 +00:00
26 lines
478 B
Bash
Executable file
26 lines
478 B
Bash
Executable file
#!/bin/sh
|
|
if [ "$1" == "-d" ]; then
|
|
shift
|
|
tail -n +11 "$@" | zstd -do "$@"~ &&
|
|
mv "$@"~ "$@"
|
|
chmod +x "$@"
|
|
else
|
|
cat > "$@"~ << 'EOF'
|
|
#!/bin/sh
|
|
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
|
|
$dir/`basename $out` $@
|
|
rm $out $dir/`basename $out`
|
|
exit $res
|
|
EOF
|
|
zstd --ultra -22 "$@"
|
|
rm "$@"
|
|
cat "$@"~ "$@".zst > "$@"
|
|
rm "$@".zst "$@~"
|
|
chmod +x "$@"
|
|
fi
|