Skip to content

Commit

Permalink
First stable release, changed name to slimcat, house keeping
Browse files Browse the repository at this point in the history
First Stable Release
--------------------
Used this program as a replacement of cat and I have fixed everything I have found

Changed Name
------------
Changed name from cat to slimcat so there is not a naming conflict
Use the makefile's unsafe-install to overwrite cat
but it is recomended to just add an alias to your shell

House Keeping
-------------
Updated copyright years
Made the code more readable
  • Loading branch information
mckenney5 committed Oct 20, 2020
1 parent 67850e8 commit 5c25cb9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
48 changes: 25 additions & 23 deletions makefile
Original file line number Diff line number Diff line change
@@ -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

16 changes: 8 additions & 8 deletions cat.1 → slimcat.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -39,7 +39,7 @@ Written by Adam McKenney
.SH "REPORTING BUGS"
See the offical repo: <https://github.com/mckenney5/slim-cat>
.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
Expand Down
8 changes: 5 additions & 3 deletions src/cat.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h> //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);
Expand Down Expand Up @@ -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;
}

0 comments on commit 5c25cb9

Please sign in to comment.