-   Programming (
-   -   environment variable does not exist (

doru 09-22-2020 09:49 AM

environment variable does not exist

$ p=password; ccrypt -eEp file.txt
ccrypt: environment variable p does not exist.
$ user@cloudm:~/tmp/test10$ export p=password; ccrypt -eEp file.txt
$ t=test; echo $t

ccrypt reads the password from p, but it sees it only when p is exported. Why?

doru 09-22-2020 09:54 AM

ccrypt works in some kind of subshell and it does not care to read the variable before it creates the subshell?!

rtmistler 09-22-2020 10:26 AM

Not sure, but you might have to use that "cat<<EOF" bash notation there. I'm pretty weak on that notation.

pan64 09-22-2020 10:28 AM

wrong syntax:

p=password ccrypt -eEp file.txt
without ; will work, but with ; it won't.
otherwise export makes the given environment variable[s] accessible in the child processes. That is the purpose of that export.

dugan 09-22-2020 05:58 PM

Expanding on the explanation above:


Originally Posted by doru (Post 6168551)

$ p=password; ccrypt -eEp file.txt

Well, with the semicolon, that's exactly equivalent to:


$ p=password
$ ccrypt -eEp file.txt

Do you see the problem?

All times are GMT -5. The time now is 10:38 PM.