Live data from Hacker News

Bash-lib: Library for bash utility methods and tools

github.com

1–10 of 25 posts

Re: Bash-lib: Library for bash utility methods and tools

#4
post #2

We need a Bash package manager and global repo now! (If you had told me in 2001 that Javascript would have had NPM and bash not, I would not have believed you.)

> bpkg is a lightweight bash package manager. It takes care of fetching the shell scripts, installing them appropriately, setting the execution permission and more.

> You can install shell scripts globally (on /usr/local/bin) or use them on a per-project basis (on ./deps/), as a lazy-man "copy and paste".

https://github.com/bpkg/bpkg

---

Also bash-lib is using bats (Bash Automated Testing System) for verification, which is un-maintained and has been forked should anybody be interested https://github.com/bats-core/bats-core

Re: Bash-lib: Library for bash utility methods and tools

#5
post #2

We need a Bash package manager and global repo now! (If you had told me in 2001 that Javascript would have had NPM and bash not, I would not have believed you.)

If you can afford using a package manager then you can afford using something more sophisticated than bash.

The whole point of bash is that it’s ubiquitous: be it an air-gapped embedded system, a recovery image or a full desktop environment, you can count on it having either bash or something reasonably close, no strings attached.

Introducing a Rube Goldberg package manager would go against this.

Re: Bash-lib: Library for bash utility methods and tools

#6
post #2

We need a Bash package manager and global repo now! (If you had told me in 2001 that Javascript would have had NPM and bash not, I would not have believed you.)

If you can afford using a package manager then you can afford using something more sophisticated than bash. The whole point of bash is that it’s ubiquitous: be it an air-gapped embedded system, a recovery image or a full desktop environment, you can count on it having either bash or something reasonably close, no strings attached. Introducing a Rube Goldberg package manager would go against this.

I can see in the use case of building up scaffolding between many different Unices to a common reference point sufficient to serve as an abstraction layer for a packaged software product to code against a generic Unix model, a Bash package manager might be useful. Some of those Bash-based abstraction layers can get relatively sprawling, and a packaging system would serve a useful role as a configuration dispatcher.

Instead of a bewildering array of case/if statements for each architecture/distro in every script, the package manager stores and deploys the platform-specific scripts, and make reading/maintaining them more streamlined. Then your case/if selection of the platform-specific environment is centralized into a single centralized location where the package manager call for installation is made.

I agree however that in an in-house setting, if I had the choice to use a package manager, then I'd be choosing a language other than Bash.

Re: Bash-lib: Library for bash utility methods and tools

#7
post #2

We need a Bash package manager and global repo now! (If you had told me in 2001 that Javascript would have had NPM and bash not, I would not have believed you.)

Interestingly, the legacy debian-installer is based on a package manager called anna (Anna's not nearly Apt), where most of the installation steps are implemented as postinst bash scripts of various udeb packages: https://salsa.debian.org/installer-team/anna#README

However, there's little documentation for any of this, and it's clearly not intended to be used for anything outside of the installer context— I couldn't even figure out how to do the equivalent of a debootstrap for an anna environment. For my own custom installer needs it turned out to be easier to use a conventional deb/apt environment and implement most of the logic in Python.

Re: Bash-lib: Library for bash utility methods and tools

#8
post #3

relevant: https://github.com/niieani/bash-oo-framework

This seems very interesting, however also dangerous.

I mean, this seems to make Bash a modern programming language, however if you do need something like this a modern scripting language like Python would be better in those cases.

Re: Bash-lib: Library for bash utility methods and tools

#9
post #8
post #3

relevant: https://github.com/niieani/bash-oo-framework

This seems very interesting, however also dangerous. I mean, this seems to make Bash a modern programming language, however if you do need something like this a modern scripting language like Python would be better in those cases.

Why is that dangerous? I mean I have seen tons of things in python where I'd say "Why didn't you just do this in bash.

Neither python nor bash exclude the other. Some things are easily solved in one, others are more easily solved in the other. And both have "escape hatches" to the other.

Re: Bash-lib: Library for bash utility methods and tools

#10
post #2

We need a Bash package manager and global repo now! (If you had told me in 2001 that Javascript would have had NPM and bash not, I would not have believed you.)

I think what we really want to fit the use case for shells is an ad hoc package standard that apt, dnf, etc can recognize.
Post reply on HN