Giter Site home page Giter Site logo

duckinator / boreutils Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 2.0 178 KB

An implementation of common *nix utilities, especially those in POSIX.1-2017.

License: MIT License

Makefile 0.63% C 59.00% Python 39.27% Shell 1.10%
posix posix-compliant cli

boreutils's Introduction

boreutils

An implementation of some of the utilities specified in POSIX.1-2017.

Excluded utilities

Boreutils focuses on non-optional utilities. Many POSIX utility categories and XSI (X/Open Systems Interfaces) utilities are excluded.

Things explicitly excluded include:

  • Things that make more sense as shell builtins, including:
    • Things that are only really usable in a shell: cd, hash, read, etc.
    • Things related to job control: bg, fg, jobs, etc.
  • Things used exclusively for printing: lp, etc.
  • The following Margin Codes:
    • CD: C-Language Development Utilities
    • FD: FORTRAN Development Utilities
    • FR: FORTRAN Runtime Utilities
    • OB: Obsolescent
    • SD: Software Development Utilities
    • UU: UUCP Utilities
  • Things that are very heavily influenced by software not in Boreutils, including:
    • Things that have terminal-specific behavior, like tput.

Things not excluded, but prone to be put off forever include:

  • Things where the standard doesn't provide enough information:
    • mesg: "The mechanism by which the message status of the terminal is changed is unspecified"
  • Things where there's no standard for the underlying functionality:
    • ps: On Linux, you read /proc. On BSD, you use kvm_getproc*(). Elsewhere? Who the heck knows.
  • Obscenely complex things, such as those involving creating archives:
    • pax

Utilities, and current status

Below is the list of POSIX.1-2017 utilities that are planned to be implemented.

Utilities that are checked off have been implemented. Partial implementations have notes explaining what is missing and a link to GitHub issues.

  • at
  • awk
  • basename
  • batch
  • bc
  • cal (August 1752 and earlier is broken. GH#4)
  • cat
  • chgrp
  • chmod
  • chown
  • cksum
  • cmp
  • comm
  • cp
  • crontab
  • csplit
  • cut
  • date
  • dd
  • df
  • diff
  • dirname
  • du
  • echo
  • ed
  • env
  • ex
  • expand
  • expr
  • false
  • file
  • find
  • fold
  • gencat
  • getconf
  • getopts
  • grep
  • head
  • iconv
  • id
  • join
  • kill (kill -l EXIT_STATUS is unimplemented. GH#7)
  • link
  • ln
  • locale
  • localedef
  • logger
  • logname
  • ls
  • m4
  • mailx
  • make
  • man (It's not very robust, and doesn't support -k. GH#8)
  • mkdir
  • mkfifo
  • more
  • mv
  • newgrp
  • nice
  • nl
  • nohup
  • od
  • paste
  • patch
  • pathchk
  • pax
  • pr
  • printf
  • ps
  • pwd
  • renice
  • rm
  • rmdir
  • sed
  • sh
  • sleep
  • sort
  • split
  • strings
  • stty
  • tabs
  • tail
  • talk
  • tee
  • test
  • time
  • touch
  • tr
  • true
  • tsort
  • tty
  • umask
  • uname
  • unexpand
  • uniq
  • unlink
  • uudecode
  • uuencode
  • vi
  • wc
  • xargs

Here are non-POSIX.1-2017 utilities which are provided:

  • dir (an extremely basic ls alternative)
  • ish (an extremely basic shell; not POSIX-compliant)
  • which (no standard)
  • whoami (no standard)
  • yes (no standard)

boreutils's People

Contributors

bors[bot] avatar duckinator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

thefresia

boreutils's Issues

Reduce number of magic arguments for `yes`

It's generally expected to accept no special flags, not even --help. Everything should just be treated as a normal argument.

Most implementations only print the first argument, so boreutils should do that too. (GNU is the only exception I'm aware of, and I don't give a fuck what they do for the most part.)

`date` can't set date with 8-digit argument

~/dev/os/awooos/boreutils master+ sudo ./bin/date 05220246
~/dev/os/awooos/boreutils master+ sudo ./bin/date 052202462020
./bin/date: Success
~/dev/os/awooos/boreutils master+

Investigate generating man pages from comments?

A decent approach โ€” at least to start โ€” may be to treat the topmost comment in src/foo.c as documentation for foo, then converting that to a .txt file and have a craptastic man implementation which is just a glorified cat that fetches files from a fixed path.

[kill] Implement `kill -l EXIT_STATUS`

I've implemented kill -l but not kill -l EXIT_STATUS

Frankly, I don't understand what https://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html is trying to tell me:

-l
(The letter ell.) Write all values of signal_name supported by the implementation, if no operand is given.
If an exit_status operand is given and it is a value of the '?' shell special parameter (see Special Parameters and wait) corresponding to a process that was terminated by a signal, the signal_name corresponding to the signal that terminated the process shall be written. If an exit_status operand is given and it is the unsigned decimal integer value of a signal number, the signal_name (the symbolic constant name without the SIG prefix defined in the Base Definitions volume of POSIX.1-2017) corresponding to that signal shall be written.
Otherwise, the results are unspecified.

(Emphasis mine.)

[man] More robust `man` implementation

The current man implementation is pretty crude, and I'd love to replace it with something better.

Any improved version would ideally also support man -k name..., but this can possibly be done with the current one as well.

[dir, mv] Add tests

At the moment, the following utilities have no tests:

  • dir
  • id
  • mv
  • which

This should be fixed.

Support `$BLOCKSIZE` environment variable

On the pages for at least df, the standard suggests the use of a BLOCKSIZE environment variable:

The use of 512-byte units is historical practice and maintains compatibility with ls and other utilities in this volume of POSIX.1-2017. This does not mandate that the file system itself be based on 512-byte blocks. The -k option was added as a compromise measure. It was agreed by the standard developers that 512 bytes was the best default unit because of its complete historical consistency on System V (versus the mixed 512/1024-byte usage on BSD systems), and that a -k option to switch to 1024-byte units was a good compromise. Users who prefer the more logical 1024-byte quantity can easily alias df to df -k without breaking many historical scripts relying on the 512-byte units.

It was suggested that df and the various related utilities be modified to access a BLOCKSIZE environment variable to achieve consistency and user acceptance. Since this is not historical practice on any system, it is left as a possible area for system extensions and will be re-evaluated in a future version if it is widely implemented.

I think it's reasonable to only support values of 512 and 1024. To the best of my knowledge, the affected utilities also all have a -k option. Given that information and the way I've implemented Boreutils utililties so far, this seems like a reasonable approach:

// after normal argument parsing is done (to avoid issues if `-k` is passed but $BLOCKSIZE != 1024).
if (!dash_k) { dash_k = strcmp(getenv("BLOCKSIZE"), "1024") == 0; }

The utilities that should have support for this are any which provide information about files and/or has a -k option that switches to 1024 byte blocks. This list should be updated if more are found:

  • df
  • ls

macOS [id] compilation error

Hi
src/id.c:75:5: error: implicit declaration of function 'getgrouplist' is invalid in C99
src/id.c:75:5: error: this function declaration is not a prototype
Regards.

[cal] Implement Julian calendar

At the moment only the hard-coded September 1752 (the month the Julian->Gregorian calendar transition happens in POSIX-compliant cal implementations) and later is implemented.

All dates before that are represented with the Julian calendar, but this needs to be implemented.

There is a j_build_month(char *buf, int y, int m) function that prints a TODO message, currently.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.