3 ms·
> #!/bin/bash I know that "portable" often means that it has no dependencies and it's self-contained, like in portableapps.com. However, in shell scripting, t
by alganet 1y ago
> #!/bin/bash
I know that "portable" often means that it has no dependencies and it's self-contained, like in portableapps.com.
However, in shell scripting, the word "portable" is often used to describe a script that is not tied to a specific interpreter (it's not a bash script, or a zsh script, it just runs in any bourne shell).
I often recommend people to do both (can run on any shell and it is self-contained requiring no external dependencies), portable in any way.
---
You could, in theory, distribute this as a single file that runs on both bash and powershell, by making a polyglot, such as this one:
https://gist.github.com/alganet/2c1c004d0580e8d92cc1c167fa4f2632 https://gist.github.com/alganet/2c1c004d0580e8d92cc1c167fa4f...
It would be called `ingest.cmd`. If you make the names of the functions the same across both, maybe you can even de-duplicate some parts of it into the part of the polyglot that addresses both interpreters (as long as that common part only deals in calling commands passing parameters).
---
> show_help() {
> echo "Usage: $0 [options] [source directory]"
> echo ""
May I introduce you to shell HEREDOCs? They're a great way to embed text, such as help snippets, directly into code without the need to resort to multiple echo calls.
https://linuxize.com/post/bash-heredoc/ https://linuxize.com/post/bash-heredoc/
- hamzakat 1y agopolyglot sounds a nice idea. i'll consider do a unified script file later. thanks for sharing.