BASH:&QUOT之差;出口K = 1"与" k等于1英寸; [英] BASH: difference between "export k=1" vs. "k=1"

查看:136
本文介绍了BASH:&QUOT之差;出口K = 1"与" k等于1英寸;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要编写一个脚本,它看起来也没有什么区别:

I am going to write an script and It looks there is no difference between:

export k=1

k=1

我说得对不对?

推荐答案

每一个过程中,即使在Windows上,有号称的环境块的内存块,这包含的环境变量的。当创建一个新的过程,在默认情况下,父进程的环境块复制到子,所以环境变量是文本数据传递到子处理的简单方法。

Every process, even on Windows, has a block of memory known as the environment block, this contains environment variables. When a new process is created, by default, the environment block of the parent process is copied to the child, so environment variables are a simple way of passing text data to a child process.

导出命令创建一个环境变量,或者一个普通的局部变量转换成一个环境变量。在C壳,它的一些可取之处之一是,它使用了不同的语法环境变量( SETENV )以局部变量(设置)。 Bourne shell的衍生物,像Bash和Korn shell中,隐藏了这一切。

The export command creates an environment variable, or converts an ordinary local variable into an environment variable. In the C-shell, one of its few redeeming features is that it uses a different syntax for environment variables (setenv) to local variables (set). Bourne shell derivatives, like Bash and Korn shell, hide all that.

目前,只有简单的值可以通过,所以像数组项(不支持它只是出口的第一要素)。可变属性,使用定义,也没有出口,除非孩子的过程是相同类型的外壳,即庆典的另一个实例集。这也适用于出口的功能,虽然它是可能的不同类型的壳之间有时破解这个(使用评估)。

Currently, only simple values can be passed, so items like arrays are not supported (it just exports the first element). Variable attributes, set using define, are also not exported unless the child process is a shell of the same type, i.e. another instance of bash. This also applies to exported functions, although it is possible to sometimes hack this between shells of different types (using eval).

在巴什(和其他人)有 allexport 称为shell设置,这意味着所有的变量是环境变量 - 可能是一个坏主意本身一般。您可以使用从语言提供不同的environemnt块类似C 的execve ,但是从外壳里,你需要像 ENV程序男人ENV 了解详情。

In Bash (and others) there is a shell setting called allexport which means all variables are environment variables - probably a bad idea to se generally. You can supply a different environemnt block from languages like C using execve, but from the shell you need a program like env, see man env for details.

这篇关于BASH:&QUOT之差;出口K = 1"与" k等于1英寸;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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