bash_profile 在文件调用后停止

0 bash

我的 .bash_profile 中有以下代码可以自动执行我需要运行的几个文件写入任务。

# Compile cron jobs for server
do_cron()
{
cd ~/Sites/MAMP/mywebsite/.ebextensions && sed 's/WEBSITE_URL/mywebsite.com/g' ./cron_jobs_sample.txt > ./cron_jobs.txt
}

# Compile config file so that we push to the right server
do_config()
{
cd ~/Sites/MAMP/mywebsite/.elasticbeanstalk/ && echo "[global]
ApplicationName=xxxx
DevToolsEndpoint=xxxx
EnvironmentName=xxxx
Region=xxxx" > ./config
}

# Do compiling
alias websitecompile=do_cron && do_config
Run Code Online (Sandbox Code Playgroud)

我只是调用:

$ websitecompile
Run Code Online (Sandbox Code Playgroud)

它运行我的任务。

问题是它运行do_cron得很好,但do_config不运行。如果我将代码切换为先运行do_config,则两者都运行良好。

alias websitecompile=do_config && do_cron
Run Code Online (Sandbox Code Playgroud)

所以do_cron似乎有些东西会杀死这个过程。我想继续扩展这些命令,所以有什么方法可以阻止它停止。

我正在运行 Max OS X Mavericks。

关于我可以做些什么来使这项工作按预期进行的任何想法?

Gor*_*son 6

脚本摘录中是否缺少引号?因为命令:

alias websitecompile=do_cron && do_config
Run Code Online (Sandbox Code Playgroud)

将别名websitecompiledo_cron,并立即执行do_config包括在别名中)。你想要的是:

alias websitecompile='do_cron && do_config'
Run Code Online (Sandbox Code Playgroud)

...这将在别名中包含这两个命令。