-
Notifications
You must be signed in to change notification settings - Fork 519
run
cannot recognize alias
#199
Comments
If you use Bash 4, you can use builtin BASH_ALIASES (refer to man page for Bash) variable to emulate aliases; Say that you want to use myAlias in test cases, then you can define a function as follows in your test helper script: In test_helper.bash
In your test case:
But if run command natively supports aliases, I think it would be much more great and convenient; |
Why not just declare a function instead of an alias? They're more reliable and don't require escaping strings:
|
Of course, we all use functions. We implement all functionalities within functions, but
This is good. But except one or two params, users may rarely use the rest of the params, which may happen in real world. Also, some params may be just for internal usage, which users don't have to know in the first place. Also, making the users type extra characters (like underscores) for your function names might be annoying from the user's perspective. One workaround is, we use aliases like so:
So users just type less characters and they don't have to focus on extra details until they seriously need to access those extra details. Of course, you may use simpler function names and wrapper functions with less params to wrap your core functions, which may look a lot user-friendly. But still, name collisions may happen when you stick to functions as your outermost interface. Of course, you need to provide users a simple mechanism to replace the default alias names with whatever names suit them best. Please, see my file search tool lf.sh for more detailed usage Or refer to z which is a more renowned project which I referenced to build lf.sh |
I have a function:
For convenient:
So I can easy to use:
and no need to type "${BASH_SOURCE[0]}" and ${LINENO} every time
When I try to test it:
I got
bats/libexec/bats-exec-test: line 58: error_msg: command not found
however, the following one is okay:
The text was updated successfully, but these errors were encountered: