You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I just started implementing Bats tests for my project. I have one function that relies on using $0 when testing (example below). How would I test this function, as $0 when bats calls the function is bats-exec-test? Or would it be best to refactor my function to not rely on $0? I've tried doing BASH_ARGV0=... run <func>, but that doesn't work. Thanks!
functionspecial() {
local var="${0##*/}"if [[ "$(basename "$var")"=="script1" ]];thenecho"Executing under script 1"elseecho"Not executing under script 1 fi}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I just started implementing Bats tests for my project. I have one function that relies on using
$0
when testing (example below). How would I test this function, as$0
when bats calls the function isbats-exec-test
? Or would it be best to refactor my function to not rely on$0
? I've tried doingBASH_ARGV0=... run <func>
, but that doesn't work. Thanks!Beta Was this translation helpful? Give feedback.
All reactions