In zsh, where the read builtin supports a -e option for echo:
termux-clipboard-set "$(IFS= read -re)"
If your system still has a line command (there's still one in util-linux but it's generally not included these days), with any POSIX-like shell:
termux-clipboard-set "$(line)"
That line command could be written as a sh function as:
line() (
IFS= read -r line; ret=$?
printf '%s\n' "$line"
exit "$ret"
)
head -n 1 does something similar except that when not reading from a terminal most implementations would read by blocks¹ and then may read more than a line from their input even if they output only one line. read and line are guaranteed not to (though you need to make sure to use the -r option for read).
With input coming from a terminal,
termux-clipboard-set "$(head -n1)"
Should work though. Most head implementations still also support the obsolete (but shorter) head -1.
With tcsh, that's:
termux-clipboard-set $<:q
¹ they also read by blocks from terminal devices, but read()s on terminal devices in icanon mode don't return more than one line.
readhere? Also, what shell are you using and what operating system? Does your shell support something liketermux-clipboard-set <<<"HG@eg3,l'{TT\"C!"?readisn't the right tool here, so focusing on how to forcereadto work is distracting from the basic question which seems to be "how can I pass a long string with special characters to the termux-clipboard-set command?".reador a pipe. I have several rules for using bash, and one is keep things simple and go one step at a time, and another is don't usereadexcept for user interaction.