3 ms·
From my understanding, explicitness of passing and usage - if your application for example logs all env variables `FOO=bar myapp` would log `FOO=bar XYZ=asd`, b
by eithed 4y ago
From my understanding, explicitness of passing and usage - if your application for example logs all env variables `FOO=bar myapp` would log `FOO=bar XYZ=asd`, but `myapp --foo=bar` would log only `foo=bar`
If two applications are setting FOO, then it results in undesired behaviour:
1. myapp1 runs, FOO=bar
2. myapp2 runs, FOO=xyz
3. myapp1 tries to use FOO, gets xyz
Instead
1. myapp1 --foo=bar runs
2. myapp2 --foo=xyz runs
3. myapp uses foo, gets bar
- jakewins 4y agoIn my example I set the env var on the same line as the command, so the env var is only set in the new process, per open group: > If the command name is not a special built-in utility or function, the variable assignments shall be exported for the execution environment of the command and shall not affect the current execution environment Eg FOO=bar myapp FOO=xyz myapp echo $FOO # prints empty string/newline
- bkfunk 4y agoThe issue is, can myapp know that it was set that way, vs being set somewhere else? The command line argument uses syntactical constraints to ensure that the value of the argument was set specifically with the intention of using it in myapp.