The runShellScript() function is either poorly documented or lacking in some features

It's not clear from the documentation what all parameters can be set by the runShellScript() function. The examples are not clear as to what exactly is being returned. Programs typically have a return code. The function appears to only return the stdout of the run command. A proper full program interface should allow native usage of stdin, stdout, and stderr as pipes.

correct, it just returns the stdout as string. Only if there is nothing in stdout and something written to stderr it will return that as string. Stdin is not supported. This can not be changed unfortunately.

If you need access to stderr in a more specific way, you could e.g. save stderr to a variable or redirect it to stdout

1 Like

That's true that it can be worked around. It's just not obvious from the documentation what is returned.

A lot of programming languages or their standard libraries provide a way to launch the program, read or write to it via a pipe, and finally receive a return code.

https://pubs.opengroup.org/onlinepubs/009696799/functions/popen.html
https://docs.python.org/3/library/subprocess.html
https://www.lua.org/manual/5.4/manual.html#pdf-io.popen

Correct, if this is needed I'd recommend to fall back to python or similar.

BTT only has a very basic scripting interface that is accessible via Apple Script and the built-in JavaScript and the custom url schemes (and optionally the built in HTTP Server if enabled), I can not provide such options with this setup unfortunately.