mirror of
https://github.com/Phantop/dotfiles
synced 2024-11-08 16:04:37 +00:00
34 lines
668 B
Bash
Executable file
34 lines
668 B
Bash
Executable file
#!/bin/sh
|
|
if [ "$1" = "-d" ]; then
|
|
shift
|
|
tail -n +11 "$1" | zstd -do "$1"~ &&
|
|
mv "$1"~ "$1"
|
|
chmod +x "$1"
|
|
exit
|
|
else
|
|
if [ "$1" = "-p" ]; then
|
|
shift
|
|
prefix="$1 "
|
|
shift
|
|
fi
|
|
|
|
{ echo '#!/bin/sh'; echo out=\`mktemp -t .zzXXXX."${1##*.}"\`; } >> "$1"~
|
|
cat >> "$1"~ << 'EOF'
|
|
dir=`dirname "$0"`
|
|
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"~
|
|
cat >> "$1"~ << 'EOF'
|
|
rm "$out" "$dir"/`basename $out`
|
|
exit $res
|
|
EOF
|
|
|
|
zstd --ultra -22 "$1" &&
|
|
cat "$1"~ "$1".zst > "$1"
|
|
rm "$1".zst "$1~"
|
|
chmod +x "$1"
|
|
fi
|