diff --git a/LICENSE b/LICENSE index 56645b0..1e8d566 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Adam McKenney +Copyright (c) 2020 Adam McKenney Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index b1d3ecb..fb77c97 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ cat — _still concatenating files and printing on the standard output, just sli This is a rewrite of GNU cat where the unused features are removed. ## Project Meta -This software is in a **working beta** state. -The software works but still needs testing before being a stable release +This software is in a **working stable** state. +The software works as inteded, currenlty bug free. ## License This code is licensed under the MIT license. See 'LICENSE' for details. diff --git a/makefile b/makefile index 887d08d..5c80875 100644 --- a/makefile +++ b/makefile @@ -1,33 +1,35 @@ -cat.out: src/cat.c - $(CC) -Wall -Ofast -o cat.out src/cat.c +slimcat.out: src/cat.c + $(CC) -Wall -Ofast -o slimcat.out src/cat.c -cat.1.gz: cat.1 - gzip -k cat.1 +slimcat.1.gz: slimcat.1 + gzip -k slimcat.1 debug: src/cat.c - $(CC) -Wall -O0 -g -o cat.debug.out src/cat.c + $(CC) -Wall -O0 -g -o slimcat.debug.out src/cat.c clean: - rm cat.*out - rm cat.1.gz + rm slimcat.*out + rm slimcat.1.gz -install: cat.out cat.1.gz - #[IMPORTANT] if you run this command twice, your original cat will be overwritten - sudo cp /usr/bin/cat /usr/bin/cat.bak - sudo cp cat.out /usr/bin/cat - sudo cp /usr/share/man/man1/cat.1.gz /usr/share/man/man1/cat.1.gz.bak - sudo cp cat.1.gz /usr/share/man/man1/ +install: slimcat.out slimcat.1.gz + # Moves compiled programs to their spots, might not work for BSD + sudo cp slimcat.1.gz /usr/share/man/man1/ + sudo cp slimcat.out /usr/bin/slimcat + # You may want to add an aliase to your shell to replace cat with slimcat -uninstall: /usr/bin/cat.bak /usr/share/man/man1/cat.1.gz.bak - sudo mv /usr/bin/cat.bak /usr/bin/cat - sudo mv /usr/share/man/man1/cat.1.gz.bak /usr/share/man/man1/cat.1.gz +uninstall: + sudo rm -v /usr/share/man/man1/slimcat.1.gz + sudo rm -v /usr/bin/slimcat + +unsafe-install: + # Makes slimcat your default cat and makes a backup of cat + sudo cp -n /usr/bin/cat /usr/bin/cat.bak + sudo cp slimcat.out /usr/bin/cat + sudo cp -n /usr/share/man/man1/cat.1.gz /usr/share/man/man1/cat.1.gz.bak + sudo cp slimcat.1.gz /usr/share/man/man1/cat.1.gz -unsafe-install: cat.out cat.1.gz - # !!! overwrites cat in /usr/bin - sudo cp cat.out /usr/bin/cat - sudo cp cat.1.gz /usr/share/man/man1/ -unsafe-uninstall: - sudo rm /usr/bin/cat - sudo rm /usr/share/man/man1/cat.1.gz +unsafe-uninstall: /usr/bin/cat.bak /usr/share/man/man1/cat.1.gz.bak + sudo mv /usr/bin/cat.bak /usr/bin/cat + sudo mv /usr/share/man/man1/cat.1.gz.bak /usr/share/man/man1/cat.1.gz diff --git a/cat.1 b/slimcat.1 similarity index 84% rename from cat.1 rename to slimcat.1 index f4bd1fc..36e3d23 100644 --- a/cat.1 +++ b/slimcat.1 @@ -1,28 +1,28 @@ -.TH CAT "1" "August 2019" "SLIM CAT BETA 1.0.0" "User Commands" +.TH SLIMCAT "1" "August 2020" "SLIM CAT 1.0.0" "User Commands" .SH NAME -cat \- still concatenating files and printing on the standard output, just slimmer. +slimcat \- still concatenating files and printing on the standard output, just slimmer. .SH SYNOPSIS .B cat [\fI\,OPTION\/\fR]... [\fI\,FILE\/\fR]... .SH DESCRIPTION .PP -This is a rewrite of GNU cat where the unused features are removed. The only option is -h for help. +This is a rewrite of GNU cat where the unused features are removed. The only option is -h for help and -u for unbuffered output. .PP We concatenate files(s) to standard output with less than 50 lines of code. .PP With no file, or when file is \-, read standard input. .SH EXAMPLES .TP -cat -h +slimcat -h Displays help. .TP -cat -u +slimcat -u Tells the OS that we dont want a buffer (warning may be a lot slower with a large file). .TP -cat x \- y +slimcat x \- y Output x's contents, then standard input, then y's contents. .TP -cat +slimcat Copy standard input to standard output. .SH "EXIT STATUS" .TP @@ -39,7 +39,7 @@ Written by Adam McKenney .SH "REPORTING BUGS" See the offical repo: .SH COPYRIGHT -Copyright \(co 2019 Adam McKenney +Copyright \(co 2020 Adam McKenney Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/cat.c b/src/cat.c index 714fd8c..f6a4855 100644 --- a/src/cat.c +++ b/src/cat.c @@ -1,9 +1,12 @@ -/* Copyright 2019 (c) Adam McKenney - See LICENSE for details */ +/* Copyright 2020 (c) Adam McKenney - See LICENSE for details */ /* A way slimmer version of cat without the GNU bloat features that I have never used nor needed */ #include //fgetc, putchar, FILE, fopen, perror, fclose, puts, fprintf -#define NAME "cat" //Program name, can be changed so a user can keep their bloated version of cat + +#define NAME "slimcat" //Program name, can be changed #define HELP "Usage: " NAME " [-hu] [file...]\nWe concatenate files(s) to standard output with less than 50 lines of code.\n\nWith no file, or when file is -, read standard input.\nExamples:\n " NAME " -h Displays the help\n " NAME " -u Tells the OS that we dont want a buffer (warning may be a lot slower with a large file).\n " NAME " x - y Output x's contents, then standard input, then y's contents.\n " NAME " Copy standard input to standard output." + static char no_buf = 0; //-u option + void throw_error(const char* extra_msg){ /* function to writes the program name, optionally extra info, then the error to stderr */ if(extra_msg != NULL) fprintf(stderr, "%s: %s: ", NAME, extra_msg); @@ -44,4 +47,3 @@ int main(int argc, char *argv[]){ else for( ; i < argc; i++) get_file(argv[i]); //step through each arg as if it's a file return 0; } -