> so I would have to create a new script for every different file I want to output to.
Not really. Since you want to use a different file (assuming dynamically generated; I can't see another way) each time, you must be in a script setting. In which case you have at least two ways to communicate your dynamic file path to the handler.
## Dynamically generated handler script
Just use a dynamically generated handler script each time. Demo:
```sh
#!/bin/sh
tmpfile="$(mktemp)"
handler="$(mktemp)"
cat >"$handler" <<EOF
#!/bin/sh
echo "\$1" >> "$tmpfile"
EOF
chmod +x "$handler"
# Poor man's coprocess.
coprocess () {
exec <"$tmpfile"
while true; do
IFS= read -r line
if [ -z "$line" ]; then
sleep 0.1
elif [ "$line" = $ ]; then
break
else
echo "handling $line"
fi
done
exec <&-
}
coprocess &
coprocess_pid=$!
googler --url-handler "$handler" "$@"
# Write a sentinel to signal EOF.
echo $ >> "$tmpfile"
wait $coprocess_pid
rm -f "$handler" "$tmpfile"
```
Sample session:
```
/tmp/demo -x googler
1. Googler - Wiktionary
https://en.wiktionary.org/wiki/Googler
EnglishEdit. EtymologyEdit · Google + -er. NounEdit. Googler (plural Googlers). A full-time Google corporation employee. A regular or habitual user of
the ...
2. jarun/googler: Google from the terminal - GitHub
https://github.com/jarun/googler
googler is a power tool to Google (Web & News) and Google Site Search from the command-line. It shows the title, URL and abstract for each result,
which can ...
3. Googler - Urban Dictionary
https://www.urbandictionary.com/define.php?term=Googler
An employee working at Google. Employee benefits include free massages, gourmet food, no set working hours, constant talks from presidential candidates
and ...
4. Googler defined - Googler dictionary definition
https://www.yourdictionary.com/googler
Googler definition: (1) A person who is an employee of Google. See Xoogler. (2) A person who uses Google to search the Internet. See Google. ...
5. How we hire - Google Careers
https://careers.google.com/how-we-hire/
6. Googlers | Google Blog - The Keyword
https://www.blog.google/inside-google/googlers/
How one Googler is raising awareness around ALS · Feb 11 / The She Word ... A Googler's illustrated guide to teamwork · Nov 2019 / Working at
Google ...
7. 19 words only Googlers understand - Business Insider
https://www.businessinsider.com/words-only-googlers-understand-2018-1
Jan 23, 2018,
Here are 19 words only Googlers will understand: ... Greyglers: Another Googler nickname, Greyglers are Google employees 40 and older ...
8. Guide: Create an employee-to-employee learning ... - re:Work
https://rework.withgoogle.com/guides/learning-development-employee-to-employee/
... through an employee-to-employee network called “g2g” (Googler-to-Googler). ... thousands of Googlers went through an Android training bootcamp run
by the ...
9. Working at Google? What does it take to be a Googler?
https://medium.com/@dinukajaya/while-i-wait-for-my-google-employment-4423f3ce50d9
Mar 11, 2016,
Google undoubtedly is one of the coolest places to work at if you are a tech enthusiast, futurist, idea maniac, business fanatic or a simple soul ...
10. Not a Googler: The Secret, Frustrating Life of a Google ...
https://fortune.com/2019/11/07/google-googler-tvc-contract-worker/
Nov 7, 2019,
More than half of Google's workers are temporary, vendor or contract staff, known as TVCs.
googler (? for help) o 1-5
googler (? for help) handling https://en.wiktionary.org/wiki/Googler
handling https://github.com/jarun/googler
handling https://www.urbandictionary.com/define.php?term=Googler
handling https://www.yourdictionary.com/googler
handling https://careers.google.com/how-we-hire/
n
1. googler — Homebrew Formulae
https://formulae.brew.sh/formula/googler
googler. Google Search and News from the command-line. https://github.com/jarun/googler · /api/formula/googler.json (JSON API) · Formula code on
GitHub.
2. Package 'googler' - CRAN
https://cran.r-project.org/web/packages/googler/googler.pdf
Package 'googler'. September 4, 2019. Title Google from the R Console. Version 0.0.1. Description This is a wrapper for the command line tool
'googler', which ...
3. Package googler - CRAN
https://cran.r-project.org/package=googler
Sep 4, 2019,
googler: Google from the R Console. This is a wrapper for the command line tool 'googler', which can be found at the following URL: ...
4. Coffee with a Googler - YouTube
https://www.youtube.com/playlist?list=PLOU2XLYxmsIJP13VD_Cg8qS5g2bKWTaYx
Coffee with a Googler. Google Developers; 64 videos; 117,122 views; Last updated on Oct 24, 2018. Play all. Share. Loading... Save ...
5. Install Googler on CentOS using the Snap Store | Snapcraft
https://snapcraft.io/install/googler/centos
Feb 10, 2020,
googler is a power tool to Google (Web & News) and Google Site Search from the command-line. It shows the title, URL and abstract for each ...
6. Googler – Google Search from your Linux Terminal | FOSS ...
https://www.fosslinux.com/25334/googler-google-search-from-your-linux-terminal.htm
Dec 22, 2019,
Googler is a powerful tool to perform Google search from the command-line. Let's check its installation and usage.
7. Chocolatey Software | googler 3.9
https://chocolatey.org/packages/googler
To install googler, run the following command from the command line or from ... googler is a power tool to perform Google Search (Web or News) from
the ...
8. #googler hashtag on Instagram • Photos and Videos
https://www.instagram.com/explore/tags/googler/
15.8k Posts - See Instagram photos and videos from 'googler' hashtag.
9. googler - Google from the command-line - Ubuntu Manpage
http://manpages.ubuntu.com/manpages/bionic/man1/googler.1.html
googler is a command-line tool to search Google (Web & News) from the terminal. Google site search works too. googler shows the title, URL and text
context for ...
10. Debian -- Details of source package googler in sid
https://packages.debian.org/source/unstable/googler
The following binary packages are built from this source package: googler: Power tool to Google (Web & News) and Google Site Search from the
terminal ...
googler (? for help) o 6-10
googler (? for help) handling https://www.fosslinux.com/25334/googler-google-search-from-your-linux-terminal.htm
handling https://chocolatey.org/packages/googler
handling https://www.instagram.com/explore/tags/googler/
handling http://manpages.ubuntu.com/manpages/bionic/man1/googler.1.html
handling https://packages.debian.org/source/unstable/googler
```
## Communicating additional info using env vars
Env vars are your friends. You can use a static handler script, writing to, say `$GOOGLER_OUTPUT_FILE`. Then you basically use the same script as the above, except calling `googler` with `GOOGLER_OUTPUT_FILE="$tmpfile"`. You can adapt the demo to this scenario.
---
So basically everywhere I look the problem is solvable. It requires a tiny bit of shell magic for sure, but the "coprocess" part is way more advanced than passing the tmpfile around, and it seems to me that the coprocess part is pretty much necessary for your use case, so the barrier of entry is already high enough.