2016-05-14 645 views
2

我是新来的bash,并试图了解下面的脚本正在做什么,我知道-e是退出,但我不知道什么-se$delimiter是什么?bash -s做什么?

$delimiter = 'EOF-MY-APP'; 

$process = new SSH(
    "ssh $target 'bash -se' << \\$delimiter".PHP_EOL 
     .'set -e'.PHP_EOL 
     .$command.PHP_EOL 
     .$delimiter 
); 
+0

'-s'从标准输入中读取命令。 http://linux.die.net/man/1/bash(来源:十秒谷歌搜索) –

+1

^^那么,'-s'是多余的?任何人都可以提供一个例子,其中'-s'是必需的吗? – anishsane

+0

Stack Overflow是编程和开发问题的网站。这个问题似乎与题目无关,因为它不涉及编程或开发。请参阅帮助中心的[我可以询问哪些主题](http://stackoverflow.com/help/on-topic)。也许[超级用户](http://superuser.com/)或[Unix&Linux堆栈交换](http://unix.stackexchange.com/)会是一个更好的地方。 – jww

回答

4

man bash

-s If the -s option is present, or if no arguments remain after 
    option processing, then commands are read from the standard 
    input. This option allows the positional parameters to be 
    set when invoking an interactive shell. 

help set

-e Exit immediately if a command exits with a non-zero status. 

所以,这是告诉bash读了剧本从Standa执行rd输入,如果脚本中的任何命令(来自stdin)失败,立即退出。

分隔符用于标记脚本的开始和结束。这被称为Here Document或heredoc。

+0

引用的部分看起来不完整:( – sjsam

+1

在这种情况下,'-s'选项是多余的,因为没有参数给脚本。 – Barmar

+1

@sjsam这是在我的Mac上运行'man' /'help'命令产生的。 – Will