QUOT之间和的差额;#!在/ usr /斌/ bash的ENV"和"#!在/ usr /斌/ bash的"? [英] The difference between "#! /usr/bin/env bash" and "#! /usr/bin/bash"?

查看:171
本文介绍了QUOT之间和的差额;#!在/ usr /斌/ bash的ENV"和"#!在/ usr /斌/ bash的"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

庆典脚本的标题,什么是这两个语句之间的区别?

In the header of a bash script, what's the difference between those two statements ?


  1. #!的/ usr / bin中/ env的庆典

#!的/ usr /斌/庆典

当我试图看到 ENV 手册页,我只是得到这样的定义:

When I tried to see the env man page, I'm just get this definition:

 env - run a program in a modified environment

这是什么意思?

推荐答案

的/ usr / bin中/ env的运行命令有寻找任何默认版本的好处方案是在当前的 ENV ironment。

Running a command through /usr/bin/env has the benefit of looking for whatever the default version of the program is in your current environment.

这样,您就不必寻找它在系统上的一个特定的地方,这些路径可能在不同系统上的不同位置。只要它在你的路径,它会找到它。

This way, you don't have to look for it in a specific place on the system, as those paths may be in different locations on different systems. As long as it's in your path, it will find it.

缺点是,因为你是不是要求一个明确的可执行文件,它有犯错误的可能,并在多用户系统的安全问题(如果有人设法得到所谓的可执行庆典在你的路径,例如)。

The downside is that since you aren't calling an explicit executable, it's got the potential for mistakes, and on multiuser systems security problems (if someone managed to get their executable called bash in your path, for example).

`#!/usr/bin/env bash` #lends you some flexibility on different systems
`#!/usr/bin/bash`     #gives you explicit control on a given system of what executable is called

在某些情况下,第一个可能是preferred(如运行带有蟒的多个版本Python脚本,而无需返工可执行行)。但在安全性是焦点的情况下,后者将是preferred,因为它限制code注射液的可能性。

In some situations, the first may be preferred (like running python scripts with multiple versions of python, without having to rework the executable line). But in situations where security is the focus, the latter would be preferred, as it limits code injection possibilities.

这篇关于QUOT之间和的差额;#!在/ usr /斌/ bash的ENV"和"#!在/ usr /斌/ bash的"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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