如何更改 perl 用于 system()、qx//和朋友的系统 shell? [英] How can I change the system shell used by perl for system(), qx//, and friends?

查看:33
本文介绍了如何更改 perl 用于 system()、qx//和朋友的系统 shell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为 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,您必须安装类似 Cygwinwin-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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆