mirror of
https://github.com/Phantop/appdwarf.git
synced 2024-11-13 02:12:54 +00:00
zzexe: fix clobbering and exit status
This commit is contained in:
parent
654eea6fab
commit
07c585bb0a
12
zzexe
12
zzexe
|
@ -3,14 +3,14 @@ set -e # exit on failure
|
|||
IFS=$(printf '\n\t') # smarter ifs
|
||||
[ "$1" = "-d" ] && awk 'f;/^exit/{f=1}' "$2" | head -c-1 | zstd -cd | ifne sponge "$2" && exit
|
||||
[ "$1" = "-p" ] && p="$2" && shift 2 # save prefix if present
|
||||
{ cat << 'EOF'; zstdmt -c19 "$@"; } | sed "2s/$/${1##*[./]})/;7s/^/$p /" | sponge "$1"
|
||||
#!/bin/sh
|
||||
zstdmt -cq19 "$@" | ifne sponge "$1"
|
||||
echo '#!/bin/sh
|
||||
dir=$(dirname "$0") out=$(mktemp -t .zzXXXX.
|
||||
awk 'f;/^exit/{f=1}' "$0" | head -c-1 | zstd -cd > "$out"
|
||||
awk "f;/^exit/{f=1}" "$0" | head -c-1 | zstd -cd > "$out"
|
||||
chmod +x "$out"
|
||||
ln -s "$out" "$dir"
|
||||
trap "res=$?" 0 1 2 3 5 10 13 15
|
||||
trap : 0 1 2 3 5 10 13 15
|
||||
"$dir/$(basename "$out")" "$@"
|
||||
res=$?
|
||||
rm "$out" "$dir/$(basename "$out")"
|
||||
exit $res
|
||||
EOF
|
||||
exit $res' | sed "2s/$/${1##*[./]})/;7s/^/$p /" | cat - "$1" | sponge "$1"
|
||||
|
|
Loading…
Reference in a new issue