[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Settor functions and initialization
>| Calling settors at startup time shouldn't be necessary at all, since all
>| the variables should be inherited from the environment unchanged (modulo
>| present bugs in closure preservation).
>
>Not true. Consider the sequence
>
>; su
>Password:
># es
>;
>
>Doing su root changes $PATH. Entering es should then set $path
>accordingly. (As I have previously pointed out, exporting both PATH and
>path is wrong since in this case the result depends on which of set-path
>and set-PATH gets called first.)
path and PATH are just a particular case. It's more complicated than that.
You cannot guess in general which variable a program might change, that you
opted to keep in sync with something else. Consider that on some systems,
LOGNAME is the canonical user name variable. On others, it's USER. I keep
them in sync so I don't have to guess which one to use, but if they are
made out of sync by su, how do you possibly determine which settor is the
correct one to call after a new shell invocation?
My solution to this (working on the assumption that settors weren't called
at startup time, which now explains some myserious directory-tracking bugs
I've not not bothered to fix) was to have a hook run by my repl each time
it's started, and add various synchronization functions there which depend
on information I've gleaned from the OS beforehand. It's insanely
complicated.
But I think in the average case, the environment is not changed from one
invocation of the shell to the next, and you can't generally expect to know
the right order in which to call settors anyway. So calling them at shell
startup is not particularly helpful.