GithubHelp home page GithubHelp logo

vlang / coreutils Goto Github PK

View Code? Open in Web Editor NEW
173.0 24.0 45.0 657 KB

This repository contains programs equivalent to GNU coreutils, written in the V language.

License: MIT License

V 99.95% Makefile 0.05%

coreutils's Introduction

coreutils in V

This repository contains programs equivalent to GNU coreutils, written in the V language.

Goal

Complete set of coreutils, written as closely as possible to the POSIX spec, with as many GNU extensions as feasible.

We are looking for solid, working implementations of the commands, not 100% 1-to-1 parity, especially not quirks and unintended side-effects.

Layout

Each command has it's own separate subdirectory under src, in case the implementor wishes to create multiple .v files to implement a command, or add a README.md specifically for that command.

Developing

Please use the common module for command line/help handling. This will make the command input/output consistent across the tools.

Building

Running make or v run build.vsh will build all the programs in bin/.

Note: support for access to user account info (via utmp) is limited to POSIX-like platforms. And, so, for Windows, utilities requiring utmp support (uptime, users, who, whoami) are currently skipped during the default build process.

Contributing

Contributions are welcome!

Please only contribute versions of the original utilities written in V. Contributions written in other languages will likely be rejected.

When your contribution is finalized, don't forget to update the completed count below and mark it as done in this README.md. Thanks!

NOTE: When testing on Windows, comparison tests are currently run against uutils/coreutils, a Rust re-implementation of GNU coreutils. They are not 100% compatiable. If you encounter different behaviors, compare against the true GNU coreutils version on the Linux-based tests first.

Completed (66/109)

Done Cmd Descripton
[ Alternate form of test
arch Print machine hardware name
b2sum Print or check BLAKE2 digests
base32 Transform data into printable data
base64 Transform data into printable data
basename Strip directory and suffix from a file name
basenc Transform data into printable data
cat Concatenate and write files
chcon Change SELinux context of file
chgrp Change group ownership
chmod Change access permissions
chown Change file owner and group
chroot Run a command with a different root directory
cksum Print CRC checksum and byte counts
comm Compare two sorted files line by line
coreutils Multi-call program
cp Copy files and directories
csplit Split a file into context-determined pieces
cut Print selected parts of lines
date Print or set system date and time
dd Convert and copy a file
df Report file system disk space usage
dir Briefly list directory contents
dircolors Color setup for ls
dirname Strip last file name component
du Estimate file space usage
echo Print a line of text
env Run a command in a modified environment
expand Convert tabs to spaces
expr Evaluate expressions
factor Print prime factors
false Do nothing, unsuccessfully
fmt Reformat paragraph text
fold Wrap input lines to fit in specified width
groups Print group names a user is in
head Output the first part of files
hostid Print numeric host identifier
hostname Print or set system name
id Print user identity
install Copy files and set attributes
join Join lines on a common field
kill Send a signal to processes
link Make a hard link via the link syscall
ln Make links between files
logname Print current login name
ls List directory contents
md5sum Print or check MD5 digests
mkdir Make directories
mkfifo Make FIFOs (named pipes)
mknod Make block or character special files
mktemp Create temporary file or directory
mv Move (rename) files
nice Run a command with modified niceness
nl Number lines and write files
nohup Run a command immune to hangups
nproc Print the number of available processors
numfmt Reformat numbers
od Write files in octal or other formats
paste Merge lines of files
pathchk Check file name validity and portability
pinky Lightweight finger
pr Paginate or columnate files for printing
printenv Print all or some environment variables
printf Format and print data
ptx Produce permuted indexes
pwd Print working directory
readlink Print value of a symlink or canonical file name
realpath Print the resolved file name
rm Remove files or directories
rmdir Remove empty directories
runcon Run a command in specified SELinux context
seq Print numeric sequences
sha1sum Print or check SHA-1 digests
sha224sum Print or check SHA-2 224 bit digests
sha256sum Print or check SHA-2 256 bit digests
sha384sum Print or check SHA-2 384 bit digests
sha512sum Print or check SHA-2 512 bit digests
shred Remove files more securely
shuf Shuffling text
sleep Delay for a specified time
sort Sort text files
split Split a file into pieces
stat Report file or file system status
stdbuf Run a command with modified I/O stream buffering
stty Print or change terminal characteristics
sum Print checksum and block counts
sync Synchronize cached writes to persistent storage
tac Concatenate and write files in reverse
tail Output the last part of files
tee Redirect output to multiple files or processes
test Check file types and compare values
timeout Run a command with a time limit
touch Change file timestamps
tr Translate, squeeze, and/or delete characters
true Do nothing, successfully
truncate Shrink or extend the size of a file
tsort Topological sort
tty Print file name of terminal on standard input
uname Print system information
unexpand Convert spaces to tabs
uniq Uniquify files
unlink Remove files via the unlink syscall
uptime Print system uptime and load
users Print login names of users currently logged in
vdir Verbosely list directory contents
wc Print newline, word, and byte counts
who Print who is currently logged in
whoami Print effective user ID
yes Print a string until interrupted

coreutils's People

Contributors

be1 avatar ccode-lang avatar crthpl avatar delta456 avatar dundee avatar flinner avatar igrekus avatar jalonsolov avatar jamespwilliams avatar lemoncmd avatar medvednikov avatar mike-ward avatar morganpeterson avatar rivy avatar ruiborda avatar schicho avatar shadowninja55 avatar sheatnoisette avatar shentengtu avatar spytheman avatar stonesword0 avatar syrmel avatar t-koba avatar taillook avatar tauraamui avatar ttytm avatar vinware avatar yuyi98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coreutils's Issues

V panic: v Files\v_windows\v\blog\mk\coreutils/bin/arch: unknown command

I execute the command v run build.vsh in Git Bash on Windows 10. It output the following message. Does anyone know how to fix this error?

User@DESKTOP MINGW64 /d/Program Files/v_windows/v/blog/mk/coreutils (main)
compiling arch...
failed cmd: v -Wimpure-v -o D:\Program Files\v_windows\v\blog\mk\coreutils/bin/arch ./arch
failed code: 1
V panic: v Files\v_windows\v\blog\mk\coreutils/bin/arch: unknown command
Run v help for usage.

v hash: d0a11f5
C:/Users/User/AppData/Local/Temp/v_0/build.4116815423438212709.tmp.c:7239: at _v_panic: Backtrace
C:/Users/User/AppData/Local/Temp/v_0/build.4116815423438212709.tmp.c:15208: by os__execute_or_panic
C:/Users/User/AppData/Local/Temp/v_0/build.4116815423438212709.tmp.c:16298: by main__main
C:/Users/User/AppData/Local/Temp/v_0/build.4116815423438212709.tmp.c:16681: by wmain
0046e408 : by ???
0046e56b : by ???
7ff8a71f7034 : by ???

Rename the project to "voreutils"

It makes sense, since this project is essentially replacing the C source with V, the name should also signify that. That way you'll also not get accused of copying the name. So, as a suggestion, I recommend replacing the letter C with V in the project's name too.

ambiguous version info

version := 'whoami (V coreutils) 0.0.1'

Is the whoami v0.0.1? Or Vcoreutils?
I'd like to suggest 1 of the following; hopefully the first:

// whoami version
version := 'whoami 0.0.1 (V coreutils)'

// V coreutils
version := 'whoami (V coreutils 0.0.1)'

Thanks for starting on this project!

Organization

It's seem kinda unorganized when I see there are all these claimed module issues, maybe instead we should create a project where every module is created an can be assigned to a user. Then we have there something like an automated kanban with 3-4 states, like TODO, In-Progress, In-Review and Done. I think this would give everyone more overview about what's already done, what is in progress and what is done. Feel free to discuss about it 😄

Small problem in wc output

Since we want these tools to be as compatible as possible with their GNU counterparts, issue like this need to be opened. The reason is that many other tools try to parse the output of the coreutils programs, and will fail if the differences are large.

I just attempted cat README.md |bin/wc -l and saw extra whitespace at the beginning of the line, and extra whitespace and a dash (-) after. Here is the output from running first the V coreutils version, the the GNU version:

jamie@5950x coreutils]$ cat README.md |bin/wc -l
  144 -
[jamie@5950x coreutils]$ cat README.md |wc -l    
144
[jamie@5950x coreutils]$

Please make the outputs match, and test the output of the other options against GNU version of wc.

Got error from `nl` command when compile prod version

PR #47
version: V 0.2.4 90e04d0

compiling nl...
failed    cmd: v -Wimpure-v -prod -o /home/shenteng-tu/projects/CONTRIBUTING/v-coreutils/bin/nl ./nl
failed   code: 1
V panic: ./nl/nl.v:152:10: error: cannot assign a reference to a value (this will be an error soon) left=[]string false right=[]string true ptr=true
  150 |     // if there are no files, read from stdin
  151 |     if args_fn.len > 0 {
  152 |         fnames = &args_fn
      |                ^
  153 |     }
  154 |

v hash: 90e04d0

implement common module `readutmp`

The commands like uptime, users, who in GNU coreutils inculde "readutmp.h" which can not be found in V, but we can make a V implementation based on <utmp.h> & <utmpx.h>.

The work is in proccess with utime implementation.

the implementation of `factor` is horrible

the current implementation of factor is laughably bad; consider using Floyd's cycle-finding algorithm with Brent's algorithms to somehow faciliate optimised Pollard's rho algorithm. It seems to be what coreutils do (+ trial division i guess), except I can't be bothered to check what kind of cycle finding algorithm do they use, since the code is, as usual for GNU, obfuscated.

Stat fails to compile because of missing file

On Mac Sonoma 14.4.1 (M2 chip)

make
compiling md5sum...
compiling cat...
compiling shuf...
compiling expand...
compiling tty...
compiling basename...
compiling truncate...
compiling echo...
compiling pwd...
compiling test...
compiling whoami...
compiling touch...
compiling unlink...
compiling sleep...
compiling logname...
compiling printenv...
compiling seq...
compiling uname...
compiling sha224sum...
compiling base64...
compiling readlink...
compiling tac...
compiling wc...
compiling nproc...
compiling expr...
compiling cksum...
compiling printf...
compiling groups...
compiling factor...
compiling head...
compiling uniq...
compiling stat...
failed    cmd: /Users/mike/Documents/github/v/v -Wimpure-v -o /Users/mike/Documents/github/coreutils/bin/stat ./stat
failed   code: 1
V panic: builder error: Header file <bits/statx.h>, needed for module `main` was not found. Please install the corresponding development headers.

v hash: 35f6523
0   build                               0x0000000100c671e4 os__execute_or_panic + 320
1   build                               0x0000000100c6c750 main__main + 3036
2   build                               0x0000000100c6cd40 main + 84
3   dyld                                0x00000001946e20e0 start + 2360
make: *** [all] Error 1```

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.