Closed balupton closed 5 months ago
Another alternative is eval_capture --if command_exists grealpath --then gnu_realpath=grealpath --elif command_exists realpath --and is_linux --then gnu_realpath=realpath
However, for complicated commands, the new function_to_command
and export -f
is suitable.
With the latest rework of
eval_capture
anddorothy test
to handle the case of conditional function invocations disabling errexit, we recommend either usingeval_capture
or rewriting the function to support a disablederrexit
and renaming it with a__
prefix. The issue with the latter, is that if this "safe" function then calls an unsafe function, which is an easy accident to do, then everything would fail as the unsafe function is still operating as if errexit is enabled.The proper solution is to have dorothy enforce
eval_capture
which always ensures the correct expectations of a function are guaranteed, rather than the travesty that is the current bash behaviour.Which would require this:
To become this:
Fortunately, GitHub Copilot eases this tedium, however expanding
eval_capture
to behave like the bash builtintest
and support these string conditionals(
,)
,!
,&&
,||
would resolve this tedium.Such a proposal will change
dorothy test
to check for the__
prefix and recommend the above instead.