How do I invoke a bash command from a non-shell application?

You can use bash's -c option to run the bash process with the sole purpose of executing a short bit of script:

    bash -c 'echo "Hi!  This is a short script."'

This is usually pretty useless without a means if passing data to it. The best way to pass bits of data to your bash environment is to pass it as positional arguments. When invoking bash this way, we can set the positional parameters like this:

    bash -c 'echo "Hi! This short script was ran with the arguments: $@"' -- "foo" "bar"

Notice the -- before the actual positional parameters. The first argument you pass to the bash process (that isn't the argument to the -c option) will be placed in $0! Positional parameters start at $1, so we put a little placeholder in $0. This can be anything you like; in the example, we use the generic --.

Alternatively, if your non-shell application allows you to set environment variables; you can do this, and then read them using normal bash variables of the same name as the environment variables.

This technique is used often in shell scripting, when trying to have a non-shell CLI utility execute some bash code, such as with find(1):

    find /foo -name '*.bar' -exec bash -c 'mv "$1" "${}.jpg"' -- {} \;

Here, we ask find(1) to run the bash command for every *.bar file it finds, passing it to the bash process as the first positional parameter. The bash process runs the mv command after doing some Parameter Expansion on the first positional parameter in order to rename our file's extension from bar to jpg.