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
@ -54,7 +54,11 @@ patchShebangs() {
|
|||||||
echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""
|
echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""
|
||||||
# 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
|
||||||
|
touch -r "$f" "$f.timestamp"
|
||||||
sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
|
sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
|
||||||
|
touch -r "$f.timestamp" "$f"
|
||||||
|
rm "$f.timestamp"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user