1
0
src/man/utilities.md
2022-05-14 20:52:07 -04:00

2.9 KiB

utilities

This project seeks to replicate all standard system utilities on UNIX-like system, implementing the features defined in POSIX.1-2017. Much of this project's layout is opinionated.

For a user installation, place PATH="$HOME/bin/:"$PATH in your $HOME/.bashrc, mkdir -p $HOME/bin, and then copy the desired utilities into that binaries folder. (Yes, this doesn't work for all system configurations (it doesn't work for mine), but it works for nearly all configurations beginners would have; if you know what you're doing you don't have to refer to this). This doesn't require root permissions and you can bypass these utilities with /bin/[desired utility].

System-wide installation of these utilities isn't recommended whatsoever.

building

You can just read the Makefile, it's a pretty simple one.

make cleanall - cleans

make programs - builds all stable utilities

make [utility] - builds a specific utility

It's not necessary to make libraries as the Makefile knows on which libraries each program depends and will build those specific libraries when needed.

included utilities

All not mentioned in this README have proper manual pages provided in man/.

abs

Not in POSIX. Shellscript that returns the absolute value of an integer argument. Relies on eq(1), lt(1), multiply(1), printf(1), and stris(1).

++

Shellscript that sums 1 with the first argument using add(1).

--

Shellscript that subtracts 1 from the first argument using subtract(1).

subtract

Shellscript that subtracts the second argument from the first. Relies on add(1), eq(1), multiply(1), printf(1), and stris(1).

cat

cat(1) written in POSIX shell. Relies on dd(1) and test(1).

eq

Compares integer arguments and exits with 0 if they're all equal or 1 if some aren't equal. Equivalent to test -eq.

fdivide

Not in POSIX. Performs floor division on two integers. This does not, as the name suggests, divide floating-point numbers.

gt

Compares integer arguments and exits with 0 if the arguments are arranged in descending order. Exits with 1 if an argument is equal or greater to a previous argument. Equivalent to test -gt.

head

An implementation of head(1) written in POSIX shell. Relies on cat(1), printf(1), sed(1), and stris(1). WIP.

lt

Compares integer arguments and exits with 0 if the arguments are arranged in ascending order. Exits with 1 if an argument is equal or lesser to a previous argument. Equivalent to test -lt.

man

Barebones implementation of man(1) written in POSIX shell.

mod

Not in POSIX. Prints the remainder of the first argument divided by the second to stdout. Written in POSIX shell, relies on eq(1), fdivide(1), multiply(1), printf(1), subtract(1), stris(1).

tail

An implementation of tail(1). WIP.