更改解释器 bash 脚本
有什么方法可以在 bash 脚本中间更改解释器
例如从以下内容开始:
#!/bin/bash
稍后更改为:
#!$drush_location
原因是因为我想使用 bash 来解析 drush 的位置,然后将该 var 作为解释器传入
Is there any way for changing the interpreter in the middle of a bash script
For instance start with:
#!/bin/bash
Later change to:
#!$drush_location
The reason is because I want to use bash to resolve the location of drush using bash and then pass that var in as an interpreter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要编写两个脚本并使用第一个 (bash) 启动第二个 (drush)。
还有其他方法可以实现此目的,但它们基本上都是执行上述操作的奇特方法。例如,您可以使用here-doc将第一个脚本中作为字符串包含的脚本填充到drush上的stdin中并让它执行,或者甚至编写一个临时文件并将其作为脚本执行,但是您必须运行两个以某种方式进行处理,您无法即时更改解释器。
实际上,要做的就是修复你的环境,以便它能够找到drush。然后你可以使用:
作为你的 drush 脚本的 hashbang。如果您的系统无法找到它,请修复您的搜索路径,直到可以找到为止!
You will need to write two scripts and use the first (bash) one to launch the second (drush).
There are other ways to accomplish this, but they are all basically fancy ways of doing the above. For example you could use a here-doc to cram a script contained as a string in your first script into stdin on drush and have it execute that, or even write a temporary file and execute that as a script, but you have to run two processes somehow, you can't change the interpreter on the fly.
Really the thing to do would be to fix your environment so that it can find drush. Then you can use:
As the hashbang for your drush script. If your system evn can't find it, then fix your search paths until it can!