#!/bin/bash
set -x

create_file() {
	rm my_file.rej my_file.orig

	cat <<EOF > my_file
/* ... */
void baz();


void baz() {
	/* ... */
}

int main() {
	int foo;
	int bar;

	/* ... */
	baz();
}
EOF
}

cat <<EOF > my_file.patch
--- my_file	2025-02-16 11:22:12.881765792 +0000
+++ my_file_new	2025-02-16 11:22:12.881796732 +0000
@@ -2,7 +2,7 @@
 void baz();
 
 void baz() {
-	/* ... */
+	// ...
 }
 
 int main() {
EOF

unset POSIXLY_CORRECT

create_file

patch -N --no-backup-if-mismatch < my_file.patch
[[ -f my_file.orig ]] && { echo ".orig backup exists when it shouldn't! (unset POSIXLY_CORRECT)" ; exit 1 ; }

exit 0
