Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use it in script with bash functions? #1

Closed
ca5ua1 opened this issue Dec 7, 2021 · 2 comments
Closed

How can I use it in script with bash functions? #1

ca5ua1 opened this issue Dec 7, 2021 · 2 comments

Comments

@ca5ua1
Copy link

ca5ua1 commented Dec 7, 2021

 ╰─λ cat test.sh 
#!/bin/bash
function func {
echo 2
}
await 'echo 1' -e 'func'

 ╰─λ test.sh 
sh: line 1: func: command not found
⣷ echo 1

I've tried to pass function with different approaches, but no result. Is it possible to pass function (without using another scripts.sh files or writing entire commands in await) in my case?

@slavaGanzin
Copy link
Owner

slavaGanzin commented Dec 21, 2021

Hi @Casul51

Await spawns a separate process for every executed command, this process is not aware of functions you created in your bash script.

If you want to call function after something awaitable, you can do it like this:

#!/bin/bash
function func {
  echo 2
}
await 'curl example.com' 'sleep 5' # blocking execution
func #prints 2 after 5 seconds

If you want to launch bash function you can do this like:

await 'bach -e"source yourfile.bash; func"'

Is it an answer to your question?

@slavaGanzin
Copy link
Owner

https://github.com/Casul51/timetable.sh/blob/main/timetable.sh#L102

I don't get what you want to achieve. So if you'll describe it to me, I can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants