patchShebangs: preserve times, resolves #33084
Close #33281. Edits by vcunat: - use Eelco's idea: empty file instead of full copy - use longer name suffix to decrease the likelihood of collision
This commit is contained in:
parent
ba6e0ae33d
commit
4b1b6ee6d1
1 changed files with 4 additions and 0 deletions
|
@ -54,7 +54,11 @@ patchShebangs() {
|
|||
echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""
|
||||
# escape the escape chars so that sed doesn't interpret them
|
||||
escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g')
|
||||
# Preserve times, see: https://github.com/NixOS/nixpkgs/pull/33281
|
||||
touch -r "$f" "$f.timestamp"
|
||||
sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
|
||||
touch -r "$f.timestamp" "$f"
|
||||
rm "$f.timestamp"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue