本文介绍了Shell脚本在make中导出环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用ksh脚本设置我的makefile以后将使用的一些环境变量.我尝试这样做:
I want to use a ksh script to set up some environment variables that my makefile will later use. I tried to do:
setup:
. myscript
但是它给了我类似[[: not found
的错误.
But it gives me errors like [[: not found
.
是否可以使用外部脚本来加载make的环境变量?
Is there a way to use an external script to load environment variables for make?
推荐答案
您可以更改makefile中使用的shell :
SHELL = /usr/bin/ksh # Or whatever path it's at
但是如果您希望脚本在其他平台上正常运行,将脚本转换为与/bin/sh
兼容的东西(最好是完全与POSIX兼容)可能是个好主意.
But it's probably a good idea to convert the script to something compatible with /bin/sh
(ideally completely POSIX-compatible) if you want it to work smoothly on other platforms.
这篇关于Shell脚本在make中导出环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!