Adding a lot more examples
parent
80d384955c
commit
4bde1486f8
@ -0,0 +1,6 @@
|
|||||||
|
# Bello
|
||||||
|
|
||||||
|
Don't forget to run chmod on the file
|
||||||
|
|
||||||
|
`chmod +x bello`
|
||||||
|
|
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# This is an example of RAW interpreted code.
|
||||||
|
|
||||||
|
|
||||||
|
printf "Hello world from Bash\n"
|
@ -0,0 +1,7 @@
|
|||||||
|
cello:
|
||||||
|
|
||||||
|
gcc -g -o cello cello.c
|
||||||
|
|
||||||
|
clean:
|
||||||
|
|
||||||
|
rm cello
|
@ -0,0 +1,38 @@
|
|||||||
|
# Patching
|
||||||
|
|
||||||
|
A patch is a source code that updates other source code. It is formatted as a diff, because it represents what is different between two versions of text. You create a __diff__ with thie `diff` utility, which is then applied to the source code using the `patch` utility.
|
||||||
|
|
||||||
|
_NOTE_: Other version control systems like git provide their own methods of creating diffs or patching software.
|
||||||
|
|
||||||
|
This is an example where we are creating a patch from the original source code using `diff` and then applying it via `patch`.
|
||||||
|
|
||||||
|
|
||||||
|
## Patching in 6 easy-ish steps
|
||||||
|
|
||||||
|
Preserve the original source code
|
||||||
|
```bash
|
||||||
|
cp cello.c cello.c.orig
|
||||||
|
```
|
||||||
|
|
||||||
|
Change the source code
|
||||||
|
|
||||||
|
|
||||||
|
Generate a patch using the `diff` utility
|
||||||
|
```bash
|
||||||
|
diff -Naur cello.c.orig cello.c
|
||||||
|
```
|
||||||
|
|
||||||
|
Save the patch to a file
|
||||||
|
```bash
|
||||||
|
diff -Naur cello.c.orig cello.c > cello-output-first-patch.patch
|
||||||
|
```
|
||||||
|
|
||||||
|
Restore the original file
|
||||||
|
```bash
|
||||||
|
cp cello.c.orig cello.c
|
||||||
|
```
|
||||||
|
|
||||||
|
Patch the original with the contents of the new patch file using the `patch` utility
|
||||||
|
```bash
|
||||||
|
patch < cello-output-first.patch
|
||||||
|
```
|
@ -0,0 +1,10 @@
|
|||||||
|
--- cello.c.orig 2019-06-25 11:46:59.195770714 -0400
|
||||||
|
+++ cello.c 2019-06-25 11:47:40.261944061 -0400
|
||||||
|
@@ -2,5 +2,6 @@
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
printf("Hello world from C\n");
|
||||||
|
+ printf("This is my first patch!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
\ No newline at end of file
|
@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
printf("Hello world from C\n");
|
||||||
|
printf("This is my first patch!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
printf("Hello world from C\n");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
__pycache__/
|
@ -0,0 +1,8 @@
|
|||||||
|
pello:
|
||||||
|
|
||||||
|
python -m compileall pello.py
|
||||||
|
|
||||||
|
|
||||||
|
clean:
|
||||||
|
|
||||||
|
rm -rf __pycache__
|
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Since we are byte compiling this, this is an interpreted example of byte compiled code
|
||||||
|
|
||||||
|
print("Hello world from Python")
|
Loading…
Reference in New Issue