When I try to run a script that contains the envsubst command, I get this error. Looking online, this seems to be a standard bash command, so I am not sure what to install in order to get it to work.
相关问题
- How to get the return code of a shell script in lu
- JQ: Select when attribute value exists in a bash a
- Invoking Mirth Connect CLI with Powershell script
- Is it possible to pass command-line arguments to @
- Emacs shell: save commit message
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- Why does popen() invoke a shell to execute a proce
- In IntelliJ IDEA, how can I create a key binding t
- Check if directory exists on remote machine with s
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Linux - change the hostname in the CLI
- Emacs/xterm color annoyance on Linux
This will enable envsubst on OS X, and force it to link properly. It requires homebrew to be installed.
I'm using this now in my bash script that requires envsubst:
you can use it as the envsubst command - of course it's not feature complete or something else:
To clear up potential confusion:
envsubst
is an external executable and thus not part of Bash; external executables are platform-dependent, both in terms of which ones are available as well as their specific behavior and the specific options they support (though, hopefully, there is a common subset based on the POSIX specifications)bash
are called builtins, and only they can be relied upon to be present on all platforms.To test whether a given command is a builtin, use
In the case at hand, running
type envsubst
on macOS 10.13 returns-bash: type: envsubst: not found
, from which you can infer:envsubst
is NOT a builtinenvsubst
is not in your system's$PATH
(and thus likely not present on your system)(By contrast, running the same on command on, e.g., a Ubuntu 12.04 system returns
envsubst is hashed (/usr/bin/envsubst)
, which tells you that the utility is present and where it is located.)A makeshift alternative to
envsubst
is to useeval
, although the usual caveat applies: useeval
only on strings whose content you control or trust:Assume a
sample.txt
file containing text with unexpanded variable references; e.g.:The equivalent of:
is:
There is a crucial difference, however:
envsubst
expands only environment variable referenceseval
will expand shell variable references too - as well as embedded command substitutions, which is what makes use ofeval
a security concern.Edit: @cobberboy 's anwer is more correct. upvote him.
Following is my old answer:
envsubst
is included ingettext
package.Therefore you may compile it by your own, using standard build tools such as
make
or usinghomebrew
.However, it seems to have little issue when installing
gettext
in MacOS. See following url for details: How to install gettext on MacOS X