patchShebangs: create timestamp in tmp dir
Creating the timestamp in the patched script's directory has a few drawbacks: * if "foo.timestamp" already exists, it will be overwritten * it requires the directory to be writable
This commit is contained in:
parent
82f338b837
commit
cc9b4029bc
@ -55,10 +55,11 @@ patchShebangs() {
|
|||||||
# escape the escape chars so that sed doesn't interpret them
|
# escape the escape chars so that sed doesn't interpret them
|
||||||
escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g')
|
escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g')
|
||||||
# Preserve times, see: https://github.com/NixOS/nixpkgs/pull/33281
|
# Preserve times, see: https://github.com/NixOS/nixpkgs/pull/33281
|
||||||
touch -r "$f" "$f.timestamp"
|
timestamp=$(mktemp)
|
||||||
|
touch -r "$f" "$timestamp"
|
||||||
sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
|
sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
|
||||||
touch -r "$f.timestamp" "$f"
|
touch -r "$timestamp" "$f"
|
||||||
rm "$f.timestamp"
|
rm "$timestamp"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user