1
0
Fork 0
mirror of https://github.com/Phantop/dotfiles synced 2024-12-25 14:46:42 +00:00
dotfiles/bin/zzexe

33 lines
631 B
Plaintext
Raw Normal View History

2021-10-26 19:01:32 +00:00
#!/bin/sh
if [ "$1" = "-d" ]; then
2021-11-13 07:32:16 +00:00
shift
tail -n +11 "$1" | zstd -do "$1"~ &&
mv "$1"~ "$1"
chmod +x "$1"
2021-10-26 19:01:32 +00:00
else
if [ "$1" = "-p" ]; then
2021-11-19 05:25:35 +00:00
shift
prefix="$1 "
shift
fi
cat > "$1"~ << 'EOF'
2021-11-13 07:32:16 +00:00
#!/bin/sh
dir=`dirname "$0"`
2021-11-13 07:32:16 +00:00
out=`mktemp -t .zzXXXX`
tail -n +11 "$0" | zstd -cd > "$out"
chmod +x "$out"
ln -s "$out" "$dir"
2021-11-13 07:32:16 +00:00
trap "res=$?" 0 1 2 3 5 10 13 15
2021-11-19 05:25:35 +00:00
EOF
echo $prefix'$dir/`basename $out` $@' >> "$1"~
cat >> "$1"~ << 'EOF'
rm "$out" "$dir"/`basename $out`
2021-11-13 07:32:16 +00:00
exit $res
2021-10-26 19:01:32 +00:00
EOF
zstd --ultra -22 "$1"
rm "$1"
cat "$1"~ "$1".zst > "$1"
rm "$1".zst "$1~"
chmod +x "$1"
2021-11-13 07:32:16 +00:00
fi