# I am the Watcher. I am your guide through this vast new twtiverse.
# 
# Usage:
#     https://watcher.sour.is/api/plain/users              View list of users and latest twt date.
#     https://watcher.sour.is/api/plain/twt                View all twts.
#     https://watcher.sour.is/api/plain/mentions?uri=:uri  View all mentions for uri.
#     https://watcher.sour.is/api/plain/conv/:hash         View all twts for a conversation subject.
# 
# Options:
#     uri     Filter to show a specific users twts.
#     offset  Start index for quey.
#     limit   Count of items to return (going back in time).
# 
# twt range = 1 5
# self = https://watcher.sour.is/conv/cwlpruq
When calling $ /bin/sh -c "$(cat foo); foo", the $(cat foo) part is evaluated in the outer sh process, so the actual argument your sh invocation is getting is:

$ /bin/sh -c "foo() {
       printf "Hello World"
}; foo"

You have the function definition there and the call which works.
When calling $ /bin/sh -c '$(cat foo); foo', the $(cat foo) part is evaluated in your sh process, so what's actually happening is $(cat foo) is trying to interpret the first "command" from the foo file, foo() which is obviously not found.
@adi Have no idea what it does to the rest of the file, on my system when having a correct command on the first line there, it just executes it and outputs the rest of the file as it is. Then it goes to the foo function call which is also not found because again there's no foo command anywhere, because the function definition wasn't parsed correctly earlier as preferred.
@adi Have no idea what it does to the rest of the file, on my system when having a correct command on the first line there, it just executes it and outputs the rest of the file as it is. Then it goes to the foo function call which is also not found because again there's no foo command anywhere, because the function definition wasn't parsed correctly earlier as preferred.
@adi I'm going to sleep.
@adi I'm going to sleep.