LIBBASH(7)

πŸ“¦
version 0.9.11 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– LIBBASH(7) πŸ’–

okay bestie, settle in, because we're talking about libbash β€” and yeah, the manual page for it lives in the LOCAL section, section 7, and the title is literally just libbash. lowercase. iconic behavior honestly.


✨ NAME ✨

libbash β€” a bash shared libraries package. that's it, that's the whole name. short, sweet, slays. πŸŽ€


🌸 DESCRIPTION 🌸

so libbash is a package that enables bash dynamic-like shared libraries. lowkey revolutionary of it. and fr fr, what it actually is, when you zoom in, is a tool for managing bash scripts whose functions you may want to load and use in scripts of your own. like a little friend group of functions you can just… borrow. 🫢

it contains a β€˜dynamic loader’ for the shared libraries (that's ldbash(1)), a configuration tool (that's ldbashconfig(8)), and some libraries. a whole little ecosystem, we love to see it. ✨

using ldbash(1) you're able to load loadable bash libraries, such as getopts(1) and hashstash(1). but here's the thing β€” a bash shared library that can be loaded using ldbash(1) must answer 4 requirements. four. not three, not five. and bestie, they are non-negotiable:

  1. It must be installed in $LIBBASH_PREFIX/lib/bash (default is /usr/lib/bash). yes, that exact path. no, you can't just vibe it somewhere else. πŸ™ˆ
  2. It must contain a line that begins with #EXPORT=. that line will contain (after the =) a list of functions that the library exports. i.e. all the functions that will be usable after loading that library will be listed in that line. if it's not in #EXPORT=, it's not coming out to play.
  3. It must contain a line that begins with #REQUIRE=. that line will contain (after the =) a list of bash libraries that are required for our library. i.e. every bash library that is in use in our bash library must be listed there. every single one. the way that dependencies will absolutely jump out if you skip one 😭
  4. The library must be listed (for more information, see ldbashconfig(8)). yes, you have to register it. it's giving bureaucracy but make it bash. πŸ’…

πŸ¦‹ Basic guidelines for writing library of your own πŸ¦‹

okay so you wanna write your own library? main character energy, we respect it. here's the tea:

  1. Be aware, that your library will be actually sourced. so, basically, it should contain (i.e define) only functions. only functions. nothing else. no stray vibes.
  2. Try to declare all variables intended for internal use as local. keep your business your business, bestie. πŸŽ€
  3. Global variables and functions that are intended for internal use (i.e are not defined in #EXPORT=) should begin with:
__<library_name>_

for example, internal function myfoosort of hashstash library should be named as

__hashstash_myfoosort

this helps to avoid conflicts in global name space when using libraries that come from different vendors. no cap, this one genuinely saves you. the namespace stays cute and unbothered. ✨

  1. See html manual for full version of this guide. yeah there's more. go read it. πŸ‘‘

πŸ’œ AUTHORS πŸ’œ

these two made it happen, show them some love:

  • Hai Zaar <haizaar@haizaar.com>
  • Gil Ran <ril@ran4.net>

🌈 SEE ALSO 🌈

the whole extended universe, go check them out:


and that's the page!! 🌟 this one's from the Linux source, dated UNDATED, and it's page LIBBASH(7) in the manual. mwah. πŸ’‹ go load some libraries bestie, you're gonna do amazing πŸ«ΆπŸ’–βœ¨
πŸ“¦ where this page comes from