admin管理员组文章数量:1356940
I am trying to figure out the difference in below code
#!/usr/bin/env expect
spawn -noecho git_script.sh
expect "Are you sure you want to continue connecting (yes/no/[fingerprint])? "
send "yes\r"
# below with dashes
send -- "yes\r"
What is the difference? In the manpage I found:
The -- flag forces the next argument to be interpreted as a string rather than a flag. Any string can be preceded by "--" whether or not it actually looks like a flag. This provides a reliable mechanism to specify variable strings without being tripped up by those that accidentally look like flags. (All strings starting with "-" are reserved for future options.)
But I dont quite understand it.
I am trying to figure out the difference in below code
#!/usr/bin/env expect
spawn -noecho git_script.sh
expect "Are you sure you want to continue connecting (yes/no/[fingerprint])? "
send "yes\r"
# below with dashes
send -- "yes\r"
What is the difference? In the manpage I found:
The -- flag forces the next argument to be interpreted as a string rather than a flag. Any string can be preceded by "--" whether or not it actually looks like a flag. This provides a reliable mechanism to specify variable strings without being tripped up by those that accidentally look like flags. (All strings starting with "-" are reserved for future options.)
But I dont quite understand it.
Share Improve this question edited Mar 27 at 23:25 Barmar 784k57 gold badges548 silver badges660 bronze badges asked Mar 27 at 23:09 Stephan KristynStephan Kristyn 15.8k15 gold badges93 silver badges158 bronze badges 01 Answer
Reset to default 2--
is needed when an argument begins with -
, but you want it to be treated literally rather than as an option, e.g. to send the string -yes
you must write:
send -- "-yes\r"
If the argument doesn't begin with -
there's no need, and --
is redundant.
If you're sending the value of a variable you should always use --
in case the value begins with -
.
本文标签: linuxWhat do the double dashes in expect doStack Overflow
版权声明:本文标题:linux - What do the double dashes in expect do? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744063845a2584623.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论