Live data from Hacker News

Ask HN: What to use instead of Bash / Sh for scripting?

news.ycombinator.com

101–106 of 106 posts

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#103
Tcl. As with other shells, the scripting model is based on commands and substitutions, but in Tcl substitution is more sane because a substitution is never reparsed and reinterpreted. Tcl was designed to provide a uniform scripting environment that could be extended into any problem domain. In this sense, is specifically intended as a generalization of the concept of a shell beyond interactive use by a logged-in user and into programmatic control of any set of subsystems. Tcl's syntax is more simple and more regular than other shells, and its semantics are designed to make it easy to create a DSL to manage the task at hand. Values are immutable in Tcl so it has the mathematical purity that is attractive in a functional language, but is much easier to get started with. Because every value is a string, there is a fexibility in Tcl that can not be found in other languages. Stringiness is interesting, fun, and productive.

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#105

Tcl. As with other shells, the scripting model is based on commands and substitutions, but in Tcl substitution is more sane because a substitution is never reparsed and reinterpreted. Tcl was designed to provide a uniform scripting environment that could be extended into any problem domain. In this sense, is specifically intended as a generalization of the concept of a shell beyond interactive use by a logged-in user…

true

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#106

A configuration management system may have you write e.g. YAML with Jinja2 so that you don't reinvent the idempotent wheel. It's really easy to write dangerous shell scripts ("${@}" vs ${@} for example) and also easy to write dangerous Python scripts (cmd="{}; {}"). Sarge is one way to use subprocess in Python. https://sarge.readthedocs.io/en/latest/ If you're doing installation and configuration, the most team-maint…

> avoid custom code and work with a configuration management system test runner

ansible-molecule is a test runner for Ansible playbooks that can create VMs or containers on local or remote resources.

You can definitely just call shell scripts from Ansible, but the (parallel) script output is only logged after the script returns a return code unless you pipe the script output somewhere and tail that .

> manual verification of `set +xev` output isn't an automated assertion.

From "Bash Error Handling" https://news.ycombinator.com/item?id=24745833 : you can display the line number in `set -x` output by setting $PS4:

  export PS4='+(${BASH_SOURCE}:${LINENO}) '
  set -x
But that's no substitute for automated tests and a test runner that produces e.g. TAP output from test runner results: http://testanything.org/producers.html#shell
Post reply on HN