I am going to write an script and It looks there is no difference between:
export k=1
and
k=1
Am I right?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.
The
exportcommand 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 (usingeval).In Bash (and others) there is a shell setting called
allexportwhich means all variables are environment variables – probably a bad idea to se generally. You can supply a different environemnt block from languages like C usingexecve, but from the shell you need a program likeenv, seeman envfor details.