mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:42:43 +00:00 
			
		
		
		
	 aaa13e5739
			
		
	
	
		aaa13e5739
		
	
	
	
	
		
			
			This is only useful for build commands that update their destination in all cases and thus sometimes confuse cmake into rebuilding everything needlessly.
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			499 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			499 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/bin/sh
 | |
| 
 | |
| set -e
 | |
| 
 | |
| if [ "$#" -lt "2" ]; then
 | |
|     echo "USAGE: $0 <file> <cmd...>"
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| DST_FILE="$1"
 | |
| shift
 | |
| 
 | |
| # Just in case:
 | |
| mkdir -p -- "$(dirname -- "${DST_FILE}")"
 | |
| 
 | |
| cleanup()
 | |
| {
 | |
|   rm -f -- "${DST_FILE}.tmp"
 | |
| }
 | |
| trap cleanup 0 1 2 3 6
 | |
| 
 | |
| "$@" > "${DST_FILE}.tmp"
 | |
| # If we get here, the command was successful, and we can overwrite the destination.
 | |
| 
 | |
| if ! cmp --quiet -- "${DST_FILE}.tmp" "${DST_FILE}"; then
 | |
|     # File changed, need to overwrite:
 | |
|     mv -f -- "${DST_FILE}.tmp" "${DST_FILE}"
 | |
| fi
 |