To cut the chase to the point, the following (originating from a Charles Duffy's reply to a related question - see his answer) would be an acceptable format for my requirements:
eval "$(
{ sed -E -e 's/^[ ]+//;' -e ':a;N;$!ba;s/\n//g' | tr -d '\n'; } <<'____COMMAND'
sshfs
foo_user@fooserver.com:/sftp_folder
/var/sshfs.sandbox/server.com
-o
user=foo_user
,reconnect
,ServerAliveInterval=15
,ServerAliveCountMax=3
____COMMAND
)"
Note that there is a trailing space whenever it is needed by the command I'm trying to split into multple lines:
sshfs
foo_user@fooserver.com:/sftp_folder
/var/sshfs.sandbox/server.com
-o
And no trailing spaces for options that have to be concatenated without an intervening blank space:
user=foo_user
,reconnect
,ServerAliveInterval=15
,ServerAliveCountMax=3
Once concatenated, the command becomes:
sshfs foo_user@fooserver.com:/sftp_folder /var/sshfs.sandbox/server.com -o user=foo_user,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3
However, I am told trailing spaces are a bad idea all around (once again, refer to Charles Duffy's reply for the motivations)
Hence I am wondering. Is there a way to achieve all these three:
- Keeping the statement all "together".
- Not having trailing whitespace.
- Making the "header" and "footer" fixed and copy pastable in other scripts without modifications.
I was thinking of using a trailing backslash and modifying the parsing expression:
{ sed -E -e 's/^[ ]+//;' -e ':a;N;$!ba;s/\n//g' | tr -d '\n'; }
so that the I can achieve all three mentioned above.