On Sat, Jul 01, 2023 at 02:45:16PM +0200, alex xmb ratchev wrote: > declare -p > works well for transmitting bash vars around via ssh > > ssh foo "$(declare -p vars) > more code"
I haven't tested that thoroughly, but it looks OK. However, it doesn't address the problem in this thread, which is that the OP wants to pass the "more code" part to ssh on standard input. A combination of your technique with what I wrote yesterday might be viable, though. { declare -p password cat <<'EOF' more code which uses "$password" EOF } | ssh user@host bash That doesn't look too bad. The "incorrectly indented EOF" can be partly solved with <<- if one uses literal tabs on the EOF line. Not all text editors (or text editor configurations) like to do that, though.