Best way to pass input to a script in Shortcuts?
- Dominant language
- Perl
- Stars
- 3.9k
- Forks
- 213
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
What I would like to do in Shortcuts to pass input to scripts (or commands) in a-Shell. Such input could be many lines of text (like, say, the text of an article). In most shell scripting environments, I would do this by passing the text input to the script on STDIN. This does not seem possible with a-Shell via Shortcuts (at least as things stand today). Is this correct?
I realize you could do something like `echo '[text]' | wc` in Shortcuts, where [text] represents a Shortcuts magic variable containing the text I want to pass as input, but this is super dangerous because if the text contains single quotes it's going to mess up the shell parsing. Shorcuts doesn't have anything like AppleScript's `quoted form of ` to automatically escape all characters that ought to be escaped for shell parsing.
Assuming it's correct, what's the next best solution? I can think of two ways:
1. Write the text input to a temporary file. This seems like a pain because (a) writing to a file in Shortcuts is a pain, and (b) there's no way to write to a-Shell's /tmp folder from Shortcuts, so any such temp files I'd have to clean up myself or just leave them around.
2. Encode the text input as a Base64 string in Shortcuts, then pass _that_ as input and add a line to decode from Base 64 within a-Shell. I gleaned this idea from this post here last year: https://github.com/holzschu/a-shell/issues/97
Any better ideas?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.