Replies: 10 comments
-
es basically executes To get the same behavior as es, your script is correct, but you are pretty much looking for the following if you want to import
Alternatively, as i said, each new es executes
If that doesn't solve your issue, more context regarding why you're using |
Beta Was this translation helpful? Give feedback.
-
Oh right, of course, the initial.es stuff doesn't use the environment in the same way. That explains it :)
Well, this is only a repro script; how I'm actually encountering this is
By the time these inferior There's certainly the The behavior I describe here is also unreliable -- if we change |
Beta Was this translation helpful? Give feedback.
-
I agree. POSIX sh uses an environment variable named Instead, maybe
Yes, that's definitely the Wrong Thing. |
Beta Was this translation helpful? Give feedback.
-
I see a couple potential options. We could imitate what The other option is to do what's suggested in http://wryun.github.io/es-shell/mail-archive/msg00837.html:
This is more "complete", allowing things like |
Beta Was this translation helpful? Give feedback.
-
That's certainly an option, but as you say, it could be potentially error-prone with
Yes, this certainly has problems as well. I think my
I'm guessing what you're actually seeking is a way to create shared variables that aren't necessarily exported, yet are still usable by all subshells, not just the login shell. I'm not saying |
Beta Was this translation helpful? Give feedback.
-
Well, here's how I see it right now: There's this established convention of "es var/UNIX var" that has been used for So based on this, what I really want are these two things:
What you're proposing with
However, it doesn't quite resolve 1 for me, so I'd still want to either get one of the better-working startup options I mention in #127 (comment), OR alternatively just stop running settor functions on startup at all. That latter choice is certainly not flaky, and it could be argued to be "correct" on the basis that on startup you're just inheriting the environment and not changing any values. The ACTUALLY (forgive my thinking-as-I-type)... in theory we could get a pretty nice compromise of all of the above:
This covers the Heck, to resolve the question of "before or after Is that too wacky? I like the idea a lot, though I also like #79, which is definitely wacky. |
Beta Was this translation helpful? Give feedback.
-
The idea of mutually-dependent variables via settor functions is certainly a problem and seemingly new ground as no other shell encourages such a dependency to my knowledge.
Pros:
Cons:
|
Beta Was this translation helpful? Give feedback.
-
Ah yes, "getter functions" are reasonably easy to hack into the shell and would provide a way to do these pairs. I've played with them before. I can't say the idea of putting them in the shell appeals to me much, though. As mentioned when this came up back in the day, es already has a mechanism for dynamically generating a value -- the function. Getter functions are somewhat redundant with both settor functions (when do I modify this value at set time and when do I modify it at reference time? are there cases where I'd want to do both?) and functions (when do I use a variable with a getter function vs. a normal function?) and they create confusing, subtle semantics for variables (when is the value of a variable not the value of that variable, and how do I reason about that?) I wouldn't want to add getter functions to es without really going through the entire shell and determining how they would be best integrated with existing shell semantics. Unless we were able to prove their worth that way, if we were to go so far as to eschew the settor-based pair for path/PATH I would honestly rather just have a And then, even after using getter functions for
So this isn't even a problem with es/UNIX var pairs; it's just generally a problem with settors (I should have led with that, but I didn't realize it at first). And this isn't all that far-fetched of an example; with readline the history file is automatically created, so it's easy to imagine that someone would want to avoid that by setting in their
which wouldn't work as desired. So I think that no matter what we wanted with |
Beta Was this translation helpful? Give feedback.
-
After a lot of reflection, i think you were right about not calling imported settors. This unfortunately doesn't resolve the issue you initially raised regarding the inability of Speaking of delayed invocation of imported settors, it's too easy to call things in the wrong order because there is no way to know that one settor might call a function, but that function might call another settor, which calls yet another settor.
I'd be wondering why the new settor called if |
Beta Was this translation helpful? Give feedback.
-
Well, this is true, but I disagree a bit with the implication. Es can't control the environment it's given, but it's under no obligation to respect the environment's ordering, so if the problem with settors on startup could be reduced to "order X works but the environment isn't guaranteed to follow it", then we could just enforce that order at import time and be golden.
Yup, this is a problem. Sadly, it's not even all that far-fetched, given invoking a binary with a relative name calls It's interesting to me how little this has been a practical issue for folks in the past. I suppose it's really because settor functions are really only used for As far as your core suggestion here (no settors + In the meantime I have a PR for the more simple/backwards-compatible fix (delayed settors at startup) done. It's simpler than I initially thought. I'll send that out. I don't think doing the simple fix blocks the more thorough, backwards-incompatible change in the future. (Maybe at that point this issue should be converted to a discussion?) |
Beta Was this translation helpful? Give feedback.
-
Repro:
I think this is discussed somewhere in the mailing list... aha, here: http://wryun.github.io/es-shell/mail-archive/msg00837.html
The fact that
foo
is innoexport
is to imitatepath
, which is due to this: http://wryun.github.io/es-shell/mail-archive/msg00763.htmlIt's not immediately clear to me why the path/PATH and home/HOME pairs in initial.es work fine but a novel pair doesn't.
Incidentally, for these kinds of pairs, it also doesn't make sense for
noexport
to benoexport
itself, because it will "forget" thatfoo
is noexport in a child shell and then in a grandchild shell,foo
will be imported from the environment which can cause the problems motivatingpath
to benoexport
.Motivation: exploring
cdpath/CDPATH
for #123 as well asls-colors/LS_COLORS
for my own use.Beta Was this translation helpful? Give feedback.
All reactions