问题描述
我想为 system
替换 perl 使用的 shell;例如用 bash 替换 Windows 上的 cmd.exe
.是否有支持的机制来告诉 perl 使用什么 shell?
I'd like to replace the shell perl uses for system
; for example to replace cmd.exe
on Windows with bash. Is there a supported mechanism to tell perl what shell to use?
推荐答案
Perl 忽略了 COMSPEC
的值,但是你可以设置环境变量 PERL5SHELL
到路径一个 shell 程序文件,以及您要使用的任何开关.例如
Perl ignores the value of COMSPEC
, but you can set the environment variable PERL5SHELL
to the path to a shell program file, together with any switches that you want to use. For instance
C:\Windows\System32\cmd.exe /d /c
Perl 将使用它来运行您传递给 qx//
和 system($command)
的命令字符串,其中 $command
包含 shell元字符
Perl will use this to run command strings that you pass to qx//
and system($command)
where $command
contains shell metacharacters
但是默认情况下 Windows 上没有 bash shell,您必须安装类似 Cygwin 或 win-bash 才能使用 bash 类型的 shell
But there is no bash shell on Windows by default, and you will have to install something like Cygwin or win-bash before you can use a bash-type shell
这篇关于如何更改 perl 用于 system()、qx//和朋友的系统 shell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!