Skip to content

Can I use coreutils as a library? #4408

Answered by tertsdiepraam
liblaf asked this question in Q&A
Discussion options

You must be logged in to vote

Technically somewhat yes, but in practice no.

Each of the utils is published as a crate and you can call their main function with some arguments. However, it still behaves exactly as the command line utils, meaning that:

  1. The arguments you give are a list of strings that are parsed like on the command line.
  2. It only returns the exit code all the other output is printed to stdout.

So the utils are not very useful as a library, but if the above is exactly what you need, it's possible. This is how the multicall binary works under the hood.

Note: we make no guarantees about the stability of using them as a library.

Does that answer your question?

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@liblaf
Comment options

@tertsdiepraam
Comment options

@liblaf
Comment options

@sylvestre
Comment options

sylvestre Feb 22, 2023
Maintainer Sponsor

Answer selected by liblaf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #4407 on February 21, 2023 13:41.