问题原文
原帖链接 · Syncopated · CC BY-SA 3.0
I have a long command-line to put into a systemd ExecStart entry. I understand I can break a long line into multiple ones by ending each non-final line with a backslash.
However, how can I document the parts with comments? E.g. the following won't work:
ExecStart=/bin/ssh -NT -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -o ServerAliveCountMax=3 \
# local tunnel for this
-L 172.16.12.34:10001:localhost:10001 \
# remote tunnel for that
-R3128:127.0.0.1:3128 \
someserver
If I remove the lines with '#', it works, but then I lose the documentation. If fine-grain in-place documentation of parts of a long command-line is fundamentally impossible, what are some useful alternatives?
社区高分解答
原帖链接 · artfulrobot · CC BY-SA 4.0
I think this is what @sven suggests:
#
# Listen locally on port 10001 and tunnel it to someserver
# Listen on someserver port 3128 and tunnel it to localhost
#
ExecStart=/bin/ssh -NT \
-o ExitOnForwardFailure=yes \
-o ServerAliveInterval=60 \
-o ServerAliveCountMax=3 \
-L 172.16.12.34:10001:localhost:10001 \
-R3128:127.0.0.1:3128 \
someserver
Doesn't look too bad to me.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
