Does a process that is not a shell process have shell variables?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
A shell (for example: the bash shell) have the concept of shell variables and the concept of environment variables.
But what about other processes that are not shell processes (for example: Firefox, gedit, etc.), do these processes also have shell variables or do they only have environment variables?
linux shell environment-variables
add a comment |Â
up vote
0
down vote
favorite
A shell (for example: the bash shell) have the concept of shell variables and the concept of environment variables.
But what about other processes that are not shell processes (for example: Firefox, gedit, etc.), do these processes also have shell variables or do they only have environment variables?
linux shell environment-variables
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
A shell (for example: the bash shell) have the concept of shell variables and the concept of environment variables.
But what about other processes that are not shell processes (for example: Firefox, gedit, etc.), do these processes also have shell variables or do they only have environment variables?
linux shell environment-variables
A shell (for example: the bash shell) have the concept of shell variables and the concept of environment variables.
But what about other processes that are not shell processes (for example: Firefox, gedit, etc.), do these processes also have shell variables or do they only have environment variables?
linux shell environment-variables
linux shell environment-variables
asked Sep 25 '17 at 8:26
user7681202
237414
237414
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
A non-shell process does not have shell variables. A C program has C variables, an awk
program has awk
variables, a Perl program has Perl variables, etc., and these are all in their own ways very much different from shell variables.
The reason another process do not have shell variables (or gets to access shell variables) is that shell variables are not exported (i.e. they are not environment variables), and also because some shells allows for attaching more information to a shell variable than just a string value, such as attributes for read-only variables, integer-only variables, etc. These type attributes (see the typeset
built-in command) can't be applied to an environment variable and be used in another process.
Some shells (like bash
) also supports arrays and associative arrays. These structures are too complex for the simple key-value pair format, where both the key (the variable name) and the value are plain text strings, imposed on environment variables, which means that these can't be exported for use in a generic other process.
All processes have access to the environment variables inherited from their parent processes. Depending on language, there are different ways for a program to access these.
A C program may use getenv()
, an awk
program may use its associative array ENVIRON
, and a Perl program may use its %ENV
hash to access environment variables, for example.
I don't know gedit
, but in vim
, you may access environment variables with a shell-like syntax:
:echo $HOME
for example. The echo
here has nothing to do with echo
in the shell, it just happens to work in a similar way. Also, the $HOME
string just happens to be the way that vim
exposes environment variables to the user.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
A non-shell process does not have shell variables. A C program has C variables, an awk
program has awk
variables, a Perl program has Perl variables, etc., and these are all in their own ways very much different from shell variables.
The reason another process do not have shell variables (or gets to access shell variables) is that shell variables are not exported (i.e. they are not environment variables), and also because some shells allows for attaching more information to a shell variable than just a string value, such as attributes for read-only variables, integer-only variables, etc. These type attributes (see the typeset
built-in command) can't be applied to an environment variable and be used in another process.
Some shells (like bash
) also supports arrays and associative arrays. These structures are too complex for the simple key-value pair format, where both the key (the variable name) and the value are plain text strings, imposed on environment variables, which means that these can't be exported for use in a generic other process.
All processes have access to the environment variables inherited from their parent processes. Depending on language, there are different ways for a program to access these.
A C program may use getenv()
, an awk
program may use its associative array ENVIRON
, and a Perl program may use its %ENV
hash to access environment variables, for example.
I don't know gedit
, but in vim
, you may access environment variables with a shell-like syntax:
:echo $HOME
for example. The echo
here has nothing to do with echo
in the shell, it just happens to work in a similar way. Also, the $HOME
string just happens to be the way that vim
exposes environment variables to the user.
add a comment |Â
up vote
2
down vote
accepted
A non-shell process does not have shell variables. A C program has C variables, an awk
program has awk
variables, a Perl program has Perl variables, etc., and these are all in their own ways very much different from shell variables.
The reason another process do not have shell variables (or gets to access shell variables) is that shell variables are not exported (i.e. they are not environment variables), and also because some shells allows for attaching more information to a shell variable than just a string value, such as attributes for read-only variables, integer-only variables, etc. These type attributes (see the typeset
built-in command) can't be applied to an environment variable and be used in another process.
Some shells (like bash
) also supports arrays and associative arrays. These structures are too complex for the simple key-value pair format, where both the key (the variable name) and the value are plain text strings, imposed on environment variables, which means that these can't be exported for use in a generic other process.
All processes have access to the environment variables inherited from their parent processes. Depending on language, there are different ways for a program to access these.
A C program may use getenv()
, an awk
program may use its associative array ENVIRON
, and a Perl program may use its %ENV
hash to access environment variables, for example.
I don't know gedit
, but in vim
, you may access environment variables with a shell-like syntax:
:echo $HOME
for example. The echo
here has nothing to do with echo
in the shell, it just happens to work in a similar way. Also, the $HOME
string just happens to be the way that vim
exposes environment variables to the user.
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
A non-shell process does not have shell variables. A C program has C variables, an awk
program has awk
variables, a Perl program has Perl variables, etc., and these are all in their own ways very much different from shell variables.
The reason another process do not have shell variables (or gets to access shell variables) is that shell variables are not exported (i.e. they are not environment variables), and also because some shells allows for attaching more information to a shell variable than just a string value, such as attributes for read-only variables, integer-only variables, etc. These type attributes (see the typeset
built-in command) can't be applied to an environment variable and be used in another process.
Some shells (like bash
) also supports arrays and associative arrays. These structures are too complex for the simple key-value pair format, where both the key (the variable name) and the value are plain text strings, imposed on environment variables, which means that these can't be exported for use in a generic other process.
All processes have access to the environment variables inherited from their parent processes. Depending on language, there are different ways for a program to access these.
A C program may use getenv()
, an awk
program may use its associative array ENVIRON
, and a Perl program may use its %ENV
hash to access environment variables, for example.
I don't know gedit
, but in vim
, you may access environment variables with a shell-like syntax:
:echo $HOME
for example. The echo
here has nothing to do with echo
in the shell, it just happens to work in a similar way. Also, the $HOME
string just happens to be the way that vim
exposes environment variables to the user.
A non-shell process does not have shell variables. A C program has C variables, an awk
program has awk
variables, a Perl program has Perl variables, etc., and these are all in their own ways very much different from shell variables.
The reason another process do not have shell variables (or gets to access shell variables) is that shell variables are not exported (i.e. they are not environment variables), and also because some shells allows for attaching more information to a shell variable than just a string value, such as attributes for read-only variables, integer-only variables, etc. These type attributes (see the typeset
built-in command) can't be applied to an environment variable and be used in another process.
Some shells (like bash
) also supports arrays and associative arrays. These structures are too complex for the simple key-value pair format, where both the key (the variable name) and the value are plain text strings, imposed on environment variables, which means that these can't be exported for use in a generic other process.
All processes have access to the environment variables inherited from their parent processes. Depending on language, there are different ways for a program to access these.
A C program may use getenv()
, an awk
program may use its associative array ENVIRON
, and a Perl program may use its %ENV
hash to access environment variables, for example.
I don't know gedit
, but in vim
, you may access environment variables with a shell-like syntax:
:echo $HOME
for example. The echo
here has nothing to do with echo
in the shell, it just happens to work in a similar way. Also, the $HOME
string just happens to be the way that vim
exposes environment variables to the user.
edited Sep 25 '17 at 8:58
answered Sep 25 '17 at 8:29
Kusalananda
106k14209327
106k14209327
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394273%2fdoes-a-process-that-is-not-a-shell-process-have-shell-variables%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password