Skip to content

rustcoreutils/posixutils-rs

Repository files navigation

posixutils-rs

This is a suite of Rust-native core command line utilties (cp, mv, rm, ls, ...) using SuSv3 as the base POSIX specification.

Goals

The goal is to create clean, race-free userland utilities that are POSIX compliant, maximizing compatibility with existing shell scripts while minimizing bloat.

Implementation goals include clean, safe Rust code and maximal use of Rust community crates. This project's utilities should "look like normal Rust programs."

Contributions are welcome. Developers and helpers, please read CONTRIBUTING for details.

Core specification: https://pubs.opengroup.org/onlinepubs/9699919799/

Non-goals

It is not a goal to be compatible with GNU utilities, which are sometimes viewed as bloated and overloaded with rarely-used options.

Popular GNU options will be supported by virtue of the "don't break scripts" rule. Unpopular options will not be implemented, to prevent bloat.

Similar projects

A similar project with the aim of GNU compatibility is https://github.com/uutils/coreutils

A similar project from the author, written in C++, is https://github.com/jgarzik/posixutils

Checklist of utilities

  • admin (SCCS)
  • ar (Development)
  • asa
  • at (cron cat.)
  • awk
  • basename
  • batch (cron cat.)
  • bc
  • c99 (Development)
  • cal
  • cat
  • cflow (Development)
  • chgrp
  • chmod
  • chown
  • cksum
  • cmp
  • comm
  • compress (compress cat.)
  • cp
  • crontab (cron cat.)
  • csplit
  • ctags (Development)
  • cut
  • cxref (Development)
  • date
  • dd
  • delta (SCCS)
  • df
  • diff
  • dirname
  • du
  • echo
  • ed
  • env
  • ex
  • expand
  • expr
  • false
  • file
  • find
  • fold
  • fort77 (Development)
  • fuser
  • gencat (i18n)
  • get (SCCS)
  • getconf
  • grep
  • head
  • iconv (i18n)
  • id
  • ipcrm (IPC)
  • ipcs (IPC)
  • join
  • kill
  • lex (Development)
  • link
  • ln
  • locale
  • localedef
  • logger
  • logname
  • lp
  • ls
  • m4
  • mailx
  • make
  • man
  • mesg
  • mkdir
  • mkfifo
  • more
  • mv
  • newgrp
  • nice
  • nl
  • nm (Development)
  • nohup
  • od
  • paste
  • patch
  • pathchk
  • pax
  • pr
  • printf
  • prs (SCCS)
  • ps
  • pwd
  • qalter (Batch cat.)
  • qdel (Batch cat.)
  • qhold (Batch cat.)
  • qmove (Batch cat.)
  • qmsg (Batch cat.)
  • qrerun (Batch cat.)
  • qrls (Batch cat.)
  • qselect (Batch cat.)
  • qsig (Batch cat.)
  • qstat (Batch cat.)
  • qsub (Batch cat.)
  • renice
  • rm
  • rmdel (SCCS)
  • rmdir
  • sact (SCCS)
  • sccs (SCCS)
  • sed
  • sh
  • sleep
  • sort
  • split
  • strings
  • strip (Development)
  • stty
  • tabs
  • tail
  • talk
  • tee
  • test
  • time
  • touch
  • tput
  • tr
  • true
  • tsort
  • tty
  • uname
  • uncompress (compress cat.)
  • unexpand
  • unget (SCCS)
  • uniq
  • unlink
  • uucp (UUCP)
  • uudecode (uue)
  • uuencode (uue)
  • uustat (UUCP)
  • uux (UUCP)
  • val (SCCS)
  • vi
  • wc
  • what (SCCS)
  • who
  • write
  • xargs
  • yacc (Development)
  • zcat (compress cat.)

Testing

A few tests require additional setup such as a case-insensitive filesystem or the use of another command like script. They are locked under the posixutils_test_all feature flag to exclude them from GitHub CI. These tests can be run by passing the feature flag to cargo:

cargo test --release --features posixutils_test_all

A further subset of posixutils_test_all tests are marked as requires_root. Running as root would override Unix permissions and thus give false failures on tests where such permissions are expected to be upheld so it is recommended to run these tests individually. There are currently two such tests:

  • test_cp_special_bits
  • test_mv_sticky_to_xpart
sudo -E cargo test --release --features posixutils_test_all,requires_root <test_name>

Integration tests may generate test data under CARGO_TARGET_TMPDIR (usually resolves to target/tmp) and /dev/shm (Linux only).