by client9

client9 /shlib

portable functions for posix shell environments

149 Stars 9 Forks Last release: Not found Other 93 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


portable functions for posix shell environments

Build Status

I've sadly written a lot of shell scripts. Mostly for installers on completely alien environments.

Really shell code should only be used for boot-strapping to something sane. Until then you might need some truly portable functions. I hope you never need to use them, but if you do they are public domain. Do whatever you'd like with them.

However acknowledgement (and pull requests) are appreciated. You can optionally include so the next person knows where to find them.


Here's an example of how create and compress a custom set of functions. Using

grep -v '^#' | grep -v ' #' | tr -s '\n'
strips away comments and blank lines.
cat \ \ \ \ \ \ \ \ | \
  grep -v '^#' | grep -v ' #' | tr -s '\n'


Some of these are new, some are these are pulled from old code I wrote. All can definitely be improved. Pull requests very welcome:

  • Simplify
  • Clean up local variable use
  • Remove any "exit 1" I may have left behind


I'm unlikely to work on this in the short term, but.. someone, someday could:

  • Probably write the test harness in go, not shell.
  • Using we can definite test ubuntu, centos and alpine/busybox using docker
  • Can we test macOS on travis? They support something here but unclear how it works.


I've start to write doco in Markdown as shell comments. The plan would be to extract it to standalone markdown so it would display on GitHub.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.