# 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 22
# self = https://watcher.sour.is/conv/ipbjj5q
@adi Perhaps you _could_ help me with something wrt to shops. Basically my colleague and I want a way to define shell functions in the config/spec (YAML) in a way that then the tool shops somehow "exports" those functions to where it the check/action items need to be run. There are two runners, local and ssh to consider. Any thoughts on this? Experiences? One thing to keep in mind is I don't particularly want to be locked into a specific shell like Bash for example. I'd rather be as POSIX as we can without too many deps...
@adi Perhaps you _could_ help me with something wrt to shops. Basically my colleague and I want a way to define shell functions in the config/spec (YAML) in a way that then the tool shops somehow "exports" those functions to where it the check/action items need to be run. There are two runners, local and ssh to consider. Any thoughts on this? Experiences? One thing to keep in mind is I don't particularly want to be locked into a specific shell like Bash for example. I'd rather be as POSIX as we can without too many deps...
@prologic I run my 'local' commands over SSH also? I remember researching this, also did some research now, seems that you can only do this with bash https://stackoverflow.com/questions/22107610/shell-script-run-function-from-script-over-ssh or something like this I guess with temp files? https://serverfault.com/questions/649359/executing-local-function-code-on-a-remote-server/686082?\n \nt\n
\nf() {\nuname\n}\n
\n\nt2\n
\n#!/bin/sh\n\n. ./t\nf\nssh -T adi@REMOTE << EOF\n$(cat t)\nf\nEOF\n
@prologic I run my 'local' commands over SSH also? I remember researching this, also did some research now, seems that you can only do this with bash https://stackoverflow.com/questions/22107610/shell-script-run-function-from-script-over-ssh or something like this I guess with temp files? https://serverfault.com/questions/649359/executing-local-function-code-on-a-remote-server/686082?

t

f() {
uname
}


t2

#!/bin/sh

. ./t
f
ssh -T adi@REMOTE << EOF
$(cat t)
f
EOF
@prologic I run my 'local' commands over SSH also? I remember researching this, also did some research now, seems that you can only do this with bash https://stackoverflow.com/questions/22107610/shell-script-run-function-from-script-over-ssh or something like this I guess with temp files? https://serverfault.com/questions/649359/executing-local-function-code-on-a-remote-server/686082?\n \nt\n
\nf() {\nuname\n}\n
\n\nt2\n
\n#!/bin/sh\n\n. ./t\nf\nssh -T adi@REMOTE << EOF\n$(cat t)\nf\nEOF\n
@adi The later is what I'm experimenting with! I'll keep going in this direction. Thank you for the validation! 🙇‍♂️
@adi The later is what I'm experimenting with! I'll keep going in this direction. Thank you for the validation! 🙇‍♂️
@adi Why does this nor work locally? 🤔

foo:

$ cat foo
foo() { printf "Hello World" }


And:


$ /bin/sh -c '$(cat foo); foo'
/bin/sh: foo(): command not found
/bin/sh: foo: command not found
@adi Why does this nor work locally? 🤔

foo:

$ cat foo
foo() { printf "Hello World" }


And:


$ /bin/sh -c '$(cat foo); foo'
/bin/sh: foo(): command not found
/bin/sh: foo: command not found
@adi Why does this nor work locally? 🤔\n\nfoo:\n
\n$ cat foo\nfoo() { printf "Hello World" }\n
\n\nAnd:\n\n
\n$ /bin/sh -c '$(cat foo); foo'\n/bin/sh: foo(): command not found\n/bin/sh: foo: command not found\n
@prologic (#ipbjj5q) Is this a valid function definition? Are we allowed to define the body on the same line?\n\n
\n$ cat foo\nfoo() { printf "Hello World" }\n$ sh foo\nfoo[1]: syntax error: 
{' unmatched\n
\n\n
\n$ cat foo\nfoo() {\nprintf "Hello World"\n}\n$ /bin/sh -c "$(cat foo); foo"\n
\n\nWorks well.\n\n
\n/bin/sh -c '$(cat foo); foo'\n
\n\nDoesn't.\n\n I guess is how newlines are processed inside double quotes as opposed to single quotes.
@prologic (#ipbjj5q) Is this a valid function definition? Are we allowed to define the body on the same line?


$ cat foo
foo() { printf "Hello World" }
$ sh foo
foo[1]: syntax error: 
{' unmatched



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


Works well.


/bin/sh -c '$(cat foo); foo'


Doesn't.

 I guess is how newlines are processed inside double quotes as opposed to single quotes.
@prologic Is this a valid function definition? Are we allowed to define the body on the same line?\n\n
\n$ cat foo\nfoo() { printf "Hello World" }\n$ sh foo\nfoo[1]: syntax error: 
{' unmatched\n
\n\n
\n$ cat foo\nfoo() {\nprintf "Hello World"\n}\n/bin/sh -c "$(cat foo); foo"\n
\n\nWorks well.\n\n
\n/bin/sh -c '$(cat foo); foo'\n
\n\nDoesn't.\n\n I guess is how newlines are processed inside double quotes as opposed to single quotes.
@prologic (#ipbjj5q) Is this a valid function definition? Are we allowed to define the body on the same line?\n\n
\n$ cat foo\nfoo() { printf "Hello World" }\n$ sh foo\nfoo[1]: syntax error: 
{' unmatched\n
\n\n
\n$ cat foo\nfoo() {\nprintf "Hello World"\n}\n$ /bin/sh -c "$(cat foo); foo"\n
\n\nWorks well.\n\n
\n/bin/sh -c '$(cat foo); foo'\n
\n\nDoesn't.\n\n I guess is how newlines are processed inside double quotes as opposed to single quotes.
@adi Wut?’ 😱
@adi Wut?’ 😱
@adi @prologic No, it's not a newline issue.
@adi @prologic No, it's not a newline issue.
@adi What’s the issue then? I’m out playing table tennis at the moment so I can’t check myself
@adi What’s the issue then? I’m out playing table tennis at the moment so I can’t check myself
@adi if the most compatible way of doing this is with new lines separating the function definition body I’m OK with that
@adi if the most compatible way of doing this is with new lines separating the function definition body I’m OK with that