我有一个简单的shell脚本,使用sudo运行,因为大多数脚本都需要它,但脚本中的一个命令是Homebrew安装,无法使用sudo执行.
所以,我的问题是当用sudo执行shell脚本时如何以当前用户身份执行子命令,然后使用sudo继续执行脚本的其余部分.
提示用户再次输入密码并不实际,因为脚本执行时间很长,需要等待5-10分钟才能显示提示.
所以我刚刚开始编写一些Ruby,虽然我理解模块是如何工作的,但以下行为仍然让我失望.
module ModuleA
def a_greet
'Hello from module A'
end
end
module ModuleB
def b_greet
'Hello from module B'
end
end
include ModuleA
include ModuleB
# WHY DOES THIS WORK !!!!!
p ModuleA.b_greet
Run Code Online (Sandbox Code Playgroud)
我知道模块中的函数可以在没有指定的情况下调用Module.,并且我永远不会以这种方式编写代码,但我不明白为什么在明确说明ModuleA时可以调用ModuleB中包含的方法?
所以,
我使用ngRepeat渲染基本列表,但首先<li>需要静态内容,而不是从数据数组生成:
例如
<ul ng-repeat="item in items">
<li>This is text from the template and will always be the same.</li>
<li>{{item}}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我也看过使用ng-repeat-start,但是不能完全找到解决方案.