You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
# fcmp - compare file identity
|
|
|
|
A small shell util that compares files for identity with `mmap()` and `memcmp()`.
|
|
|
|
# Usage
|
|
`fcmp` produces no output, but success is indicated by its return code.
|
|
|
|
```shell
|
|
$ fcmp file1 file2 && echo "Equal!"
|
|
```
|
|
|
|
You can pass any number of files, but at least 2 must be provided.
|
|
|
|
| Code | Meaning |
|
|
|------|--------------------------------------------------------------|
|
|
| 0 | The files are equal |
|
|
| 1 | The files are unequal |
|
|
| 2 | The files have unequal lengths, and therefor must be unequal |
|
|
| -1 | There was an error |
|
|
|
|
You can use this in shell scripts easily:
|
|
|
|
``` shell
|
|
# Example
|
|
|
|
if fcmp "$1" "$2"; then
|
|
echo "Files are equal!"
|
|
else
|
|
echo "Files are not equal!"
|
|
fi
|
|
```
|
|
|
|
# Building
|
|
To build normally, run `make`.
|
|
|
|
## Release target
|
|
Build with default optimisations using `make release`, it will output a stripped binary at `fcmp-release`.
|
|
|
|
### Notes
|
|
* The Makefile uses variables `RELEASE_CFLAGS` and `RELEASE_LDFLAGS` to apply optimisations (and `DEBUG_CFLAGS` + `DEBUG_LDFLAGS` for extra compiler flags with the debug target). If needed you can set these yourself to prevent the defaults.
|
|
* The default `RELEASE_CFLAGS` specify `-march=native` which may be undesireable for you. Set the variable or modify the Makefile if you need to remove this.
|
|
|
|
## Debug target
|
|
Build with debugging information and no optimisations using `make debug`, it will output a binary at `fcmp-debug`.
|
|
|
|
## Note
|
|
Before switching between `release` and `debug` targets, make sure to run `make clean`.
|
|
|
|
# License
|
|
GPL'd with <3
|