yujiri.xyz

Software

Learn programming for good instead of profit

Process environment

On Unix-like operating systems, one way a process can take input its through its "environment", which is a set of variables automatically inherited from the process that started it (its "parent process"). For example, when you start a program from your shell, it inherits your shell's environment. So, what kind of variables are in your shell's environment?

One of them is HOME, which is set to the absolute path to your home folder. (They are usually named in all caps.) You can see it by running `echo $HOME`. If you haven't seen it already, `echo` is a shell command that just prints whatever text you give it to stdout, and the $ symbol tells your shell that `HOME` is not literal text but the name of an environment variable. So, any program you start from the shell can find out what your home folder is by reading this variable from its environment.

Another one is PATH, which is a list of folder paths, separated by colons, that commands are installed in. When you type a command like `ls`, your shell looks at the PATH variable in its environment, and tries to find the `ls` binary inside one of those folders. Try `echo $PATH`. You'll probably see something like `/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin`. Also, feel free to `ls` any of those folders to see which commands they contain.

Your environment probably has a bunch of other, relatively obscure things in it. You can see all of them with the command `env`.

Now, compare four different ways a process can take input: arguments, environment, stdin, and configuration files. Consider what each is best used for.

arguments:

environment:

stdin:

configuration files:

Proxied content from gemini://yujiri.xyz/software/guide/env.gmi

Gemini request details:

Original URL
gemini://yujiri.xyz/software/guide/env.gmi
Status code
Success
Meta
text/gemini; lang=en
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.

What is Gemini?