2021-10-26 19:01:32 +00:00
|
|
|
#!/bin/sh
|
2022-01-18 17:25:01 +00:00
|
|
|
if [ "$1" = "-d" ]; then
|
2021-11-13 07:32:16 +00:00
|
|
|
shift
|
2022-01-18 17:25:01 +00:00
|
|
|
tail -n +11 "$1" | zstd -do "$1"~ &&
|
|
|
|
mv "$1"~ "$1"
|
|
|
|
chmod +x "$1"
|
2022-02-19 04:04:40 +00:00
|
|
|
exit
|
2021-10-26 19:01:32 +00:00
|
|
|
else
|
2022-01-18 17:25:01 +00:00
|
|
|
if [ "$1" = "-p" ]; then
|
2021-11-19 05:25:35 +00:00
|
|
|
shift
|
|
|
|
prefix="$1 "
|
|
|
|
shift
|
2022-02-19 04:04:40 +00:00
|
|
|
fi
|
2022-01-20 21:05:36 +00:00
|
|
|
|
2022-02-19 04:04:40 +00:00
|
|
|
{ echo '#!/bin/sh'; echo out=\`mktemp -t .zzXXXX."${1##*.}"\`; } >> "$1"~
|
|
|
|
cat >> "$1"~ << 'EOF'
|
2022-01-18 17:25:01 +00:00
|
|
|
dir=`dirname "$0"`
|
|
|
|
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
|
2022-01-20 21:05:36 +00:00
|
|
|
echo "$prefix"'$dir/`basename $out` $@' >> "$1"~
|
2022-01-18 17:25:01 +00:00
|
|
|
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
|
2022-01-20 21:05:36 +00:00
|
|
|
|
|
|
|
zstd --ultra -22 "$1" &&
|
2022-01-18 17:25:01 +00:00
|
|
|
cat "$1"~ "$1".zst > "$1"
|
|
|
|
rm "$1".zst "$1~"
|
|
|
|
chmod +x "$1"
|
2021-11-13 07:32:16 +00:00
|
|
|
fi
|