« first day (2298 days earlier)      last day (852 days later) » 

11:18 AM
I have a very tricky, involved question regarding fundamentals of the shell.
I spent several hours looking into it today (yes, on a Sunday) and at least an hour writing up the research and reasoning.
0
Q: Can an interactive shell become non-interactive or vice versa?

WildcardCan an interactive shell become non-interactive or vice versa? Note: I've done a lot of research on the basic question, "What is the difference between interactive and non-interactive?", and the results of my research led me to ask this question. This question has a long preamble in part becaus...

@StéphaneChazelas, if you get a chance I would love to get your slant on this subject. :)
@schily, also, if you can see this ping.
 
Interesting question. The usual way for a utility to check whether it's run interactively or not (i.e. as part of a pipeline) is to check whether stdin and stdout are connected to a TTY.
For example, a non-interactive sub-shell: echo hello | ( tty; cat ).
 
@Kusalananda Yep, that would be an example of the fact that "interactive" is really just a common label rather than a totally precise item.
So utilities which check TTY have a good proxy. But if the shell is run with bash -i, then it's not saying whether the shell is "interactive."
Point being (as noted in my question), that I don't think "interactive" is really a finite definite thing. But there are certainly behaviors of the shell which indicate that the TTY connections and $- check are not all the ways that "interactive" is noted or stored by the shell.
 
11:52 AM
Heh, is that you @Wildcard upvoting my questions about interactive shells? Looks like you're doing your homework :)
And very interesting question, by the way. Although a bit on the long side. On the other hand, I don't see where else you could put your research so. . .
 
The question is borderline philosophical.
I an start an interactive shell and then tear down the job control, close the streams, unset $- etc.
At what point does it become "non-interactive"?
 
@Wildcard Trivia point - I don't think a capital after a colon is correct.
 
It's not a question with any practical application that I can see.
 
12:10 PM
It's Unix philosophy. How about unixosophy?
 
It's like a discussion around the concept and definition of "being alive" at any of the extreme points at "birth" and "death".
 
@terdon Correct guess :)
@terdon Yeah, I know. I occasionally (while I was writing and scrapping and rewriting the question over like a 4 hour period) considered just reducing to one sentence: "Does set +i actually do anything?" but it made me feel like crying with exasperation, and it wouldn't have really accomplished anything—
(since evidently the answer is "no," but I don't understand how that's possible). So I decided to just emphasize all the actual questions in there and leave the research in place as well.
@Kusalananda That's true. BUT! See my comments on Stephane's answer.
@Kusalananda THAT question would be irrelevant and unanswerable. But there are a few specific, concrete behaviors of what's called an "interactive shell" that cannot be understood (or changed!) by reference to the documentation. I want to know how those "options" (behaviors) are registered or kept track of, since they seem to be magically remembered regardless of tearing down job control, closing streams, etc.
(I didn't try all teardown possible, but I did enough to make an interesting question.)
 
What if "being an interactive shell" is just a shell initialization thing? The shell enables job control and all the other things. After that, does it have to know it's "interactive"?
A collection of behaviours.
 
@Kusalananda Originally I just wanted to understand what "interactive" meant, fundamentally. I answered that satisfactorily for myself. Individual traits of a default interactive shell can be checked for individually (shopt -o histexpand, etc.), and there is no single global trait that qualifies a shell as "interactive."
 
Just as with my "being alive" analogy. I ask "are you alive?". You say "yes", but how do you know? You don't wear a "being alive" thing that someone can take away, but you can check distinct things like thinking, breathing, able to move etc.
 
12:24 PM
The only remaining thing left to clear up, then, are the few behaviors for which I don't even see or understand how the shell registers or remembers (or changes) those behaviors. They are part of the nebulous "interactiveness" of the shell, and aren't predictable otherwise.
 
12:38 PM
@Kusalananda Hence my preamble about action definitions. A label is a label. The things you label with it are so labeled. That doesn't make it possible to do anything with that label. It's a "descriptive definition" only, not dynamic in the slightest. If you define the label "alive" as applying to a person who has stopped breathing, but only if they are still warm and are not underwater—then that person is "alive" by your definition. Great. Useless.
By contrast, you could take a dynamic concept like "possible to resuscitate if given immediate attention, but otherwise certain to remain dead," and now you have an action definition. You can do something with this definition. You can use it to bring about a changed condition (changed state of being) on the part of this item of interest. Or bring about action or inaction. Use it to accomplish something else. It has a purpose.
 
 
3 hours later…
3:30 PM
I can't decide whether unix.stackexchange.com/questions/339541/… is off-topic or just unclear... I'm lacking context with this one.
 
 
1 hour later…
4:49 PM
anthony@Zia:~$ ps u 4625
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
anthony   4625  3.3  7.6 44897876 1890900 ?    Sl   Jan03 978:53 plasmashell --s
Appears KDE has been infected by browser-itis.
a blinking icon in the systray is causing it to up its VSZ amazingly, and RSS somewhat. On every blink.
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
anthony   4625  3.4  7.0 22754580 1747864 ?    Sl   Jan03 979:57 plasmashell --shut-up
... very bad case of browser-itis.
 
5:30 PM
@derobert browser-itis?
 
@FaheemMitha Disease that infects all major browser vendors, where whatever amount of RAM you have isn't enough
And they constantly leak memory, and slow down, until you restart them.
Sort of like how Windows used to be.
 
@derobert Oh, that. Yes.
I figure it can't be that hard to avoid memory leaks. But I guess you have to care.
 
I'm sitting with a piece of scientific software that has a load of function pointers and void * data structures everywhere. It's hairy, and it leaks. It's very tricky to even see what structures leak sometimes, and even more tricky to figure out how to properly deallocate them when the allocations happens in all sorts of places at different times.
I was going to say "that's academic software development for you" but then I'd be shooting myself in the foot, being an academic software developer...
 
@Kusalananda I thought that's what smart pointers were for. But why not just use languages with garbage collection?
 
Valgrind is a big help, but I wouldn't want to have to run a browser through Valgrind and then have to track don all the leaks.
@FaheemMitha It's C. The software is 10+ years old. It has a big user-base, and it's in "maintenance mode", which is why I have been entrusted with maintaining it (it's one of the things we do).
 
5:40 PM
For example, some Common Lisp implementations have garbage collection and are still fast.
@Kusalananda I feel for you.
I don't understand why people write stuff in C.
It might make sense if you are writing a Unix kernel.
 
@FaheemMitha Bioinformatics isn't well known for its Common Lisp usage ;-)
 
@Kusalananda That's a shame.
 
It's Perl or Python most of the time, when it isn't R or Excel spreadsheets.
 
Though writing a well-performing GC is not easy, I believe.
@Kusalananda Yes, I'm aware. I have a bit of experience in the area myself. Not as much as yours, though.
 
Boehm-gc is what I use if I need garbage collection in my C programs.
Great leak finder too.
 
5:43 PM
@Kusalananda Sure. Though I didn't specifically mean C.
 
Right. C just happens to be what I'm using when I do my own coding.
 
Anyway, Anthony was talking about browsers, which is production code. I think people writing browsers should be able to avoid memory leaks.
 
Depends on where it leaks. You can't do much about a leak in a library.
 
@Kusalananda Good point.
@Kusalananda Do you actually like writing in C?
 
@Kusalananda I have no idea where exactly Chrome leaks, but Firefox is maybe in JS or DOM. Leaving some pages open take out the browser pretty quickly, others not at all.
I've often wondered if Firefox wouldn't work better if you added a half TB of swap and disabled its garbage collector
 
5:58 PM
:-)
 
Because it's GC has the problem that it hangs the browser for hundreds of ms, and fails to collect any garbage. Then it repeats a few seconds later. Until you eventually give in and restart the browser.
chat.SE used to be one of those sites that'd kill it in a day or two. Not sure if it still does, but that's why I use Chromium—mainly for chat.SE.
 
6:10 PM
@FaheemMitha Yes, I actually do like writing in C. It's enjoyable. :-)
 

« first day (2298 days earlier)      last day (852 days later) »