我希望在bash脚本中嵌入这样一个长命令:
mycommand \
--server myserver \
--filename extremely/long/file/name/that/i/would/like/to/be/able/to/break/up/if/possible \
--otherflag \
--anotherflag
将长文件名分开。
我可以这样做:
# Insufficiently pretty
mycommand \
--server myserver \
--filename extremely/long/file/name/\
that/i/would/like/to/be/able/to/break/\
up/if/possible \
--otherflag \
--anotherflag \
但这会破坏整个流程。我希望能够像这样书写:
但它会破坏整个流程。我希望能够这样写:
# Doesn't work
mycommand \
--server myserver \
--filename extremely/long/file/name/\
that/i/would/like/to/be/able/to/break/\
up/if/possible \
--otherflag \
--anotherflag
但这样做不起作用,因为它会打断字符串字面量。
有没有办法告诉bash打破字符串字面量,但忽略任何前导空格?
\``)放在前一行的末尾,而不是使用反斜杠(
\`)进行换行…… 这样可以保持左侧的整齐。 - Peter.O"one\
[换行] [空格] `two"->
"onetwo"` - OLEGSHA