开发者

Changing interpreter bash script

Is there any way for changing the interpreter in the middle of a bash scrip开发者_如何学编程t

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


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:

#!/usr/bin/env drush

As the hashbang for your drush script. If your system evn can't find it, then fix your search paths until it can!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜