4 ms·
You should always type check your shell scripts as well. For example, you just: $ shelltypes script.sh # Welcome to shelltypes v 3.23.2 # type ‘hel
by apgwoz 2y ago
You should always type check your shell scripts as well. For example, you just:
$ shelltypes script.sh
# Welcome to shelltypes v 3.23.2
# type ‘help’ if you’re stuck
>>> {1) # import POSIX;;
Importing 73 items.
>>> {2} # append loadpath “/opt/local/shelltypes/base”;;
>>> {3} # import base::YOURPROJECT;;
Importing 15 items.
>>> {4} # check “YOURSCRIPT.sh”
Parsing YOURSCRIPT.sh.
Reticulating splines.
Expanding aliases.
Analyzing free shell environment variables.
Found inconsistencies in PATH.
Warning: Low battery!!!
Warning: found free type for ‘shred’, ignoring.
Warning: use of sudo requires password under /etc/sudoers.
Warning: this utility is fake.
Error: use of cat impossible in the presence of mutt.
Found 15 errors.
Try again. Goodbye.
$
Then you can be pretty sure your script isn’t going to do unnecessary harm, and has some proper guardrails in place.
- Timon3 2y agoWhere does "shelltypes" come from? I can't find anything on DuckDuckGo or Google, but this seems like it would be very useful.
- Arrowmaster 2y agoFrom the output in the post I'm going to assume it's either a joke post or an LLM hallucination.
- Timon3 2y agoOh god, it even says right there: > Warning: this utility is fake. Well played! I guess I got too excited at the possibility of such a tool existing.
- OJFord 2y agoSuch a tool does exist, it's called shellcheck. If you give /bin/sh shebang for example it will tell you off using non-POSIX features regardless of whether they'll work with the sh on your system. (Personally I typically use bash though, largely so I can `set -eEuo pipefail` next.)
- apgwoz 2y agoThe thought is very compelling! shellcheck is pretty great, but of course isn’t this complete. It definitely can’t reticulate splines, for instance.
- deleted 2y ago[deleted]
- amelius 2y agoI don't know shelltypes, and it sounds like a linter for shell scripts. Does shelltypes warn against a failure to check for ARG_MAX?