I am writing a bash script on my mac and when I call a function with the open command it gets stuck in a loop.
For example:
function (){
open https://www.example.com
}
I have tried putting some echo commands in between the open command to see what happens.
If I do the following:
function (){
echo "checkpoint 1"
open https://www.example.com
echo "checkpoint 2"
}
I get the following output:
checkpoint 1
checkpoint 1
checkpoint 1
checkpoint 1...
If I isolate the command outside of the function then the script behaves as expected.
Any help is greatly appreciated.
open
? Check withfunctions open
ortypeset -f open
in thezsh
shell (which is the shell I'm assuming you're using as you are using anonymous functions). I can not reproduce the behavior that you describe. – Kusalananda Dec 25 '21 at 20:31bash
. Perhaps you called the functionopen
(and thus haveopen()
calling itself), in which case you can usecommand open
within the function. @they, from https://stackoverflow.com/q/264395, it seems thatopen
is a command similar toxdg-open
. – rowboat Dec 26 '21 at 02:38zsh
. I don't see the use of it here, but the syntax is correct forzsh
. I know whatopen
is on macOS (I have access to macOS too). I was mostly wondering whether the anonymous function was called from within another function namedopen
. – Kusalananda Dec 26 '21 at 07:14