Stale view of filesystem in a bash session

[Strange situation on 10.13.6 (17G65)]

Amongst a bunch of Terminal tabs, I had two with the same working directory but in one what I saw with "ls -lrta" was stale.


I tend to keep my MBP up and signed in for many days between shutdown/restart. Before I shutdown/restart I go through my Terminal tabs and execute something like "history > history2" since I've had Terminal start up and forget all my previous sessions too many times. Last night I was aware that the next tab I went to do this in was in the same directory as the previous tab, so as I tab-completed the output filename (eg. history2) I fully expected to have to adjust the 2 to a 3. However, it seemed that only the file "history" existed. Doing an "ls -lrta" in each I could see that they were largely the same directories by content/timestamps but the last few files were either missing or stale in the second bash session.


Has anyone seen something like this, know if it's a known bug, or related to some feature that I may be unaware of?


Thanks,

Steven

Replies

That is... unexpected.


I don't see how the ls command could've been reading different directory data in each of the two Terminal sessions. The ls command is calling opendir/readdir and those are hooks into the OS's support for reading directories, and the kernel is going to pull data from the cache of directory entries, so... they should both show the same thing.


Do you have any other details? What are the full paths for both directories? Did either path make use of symbolic links or macOS aliases?

This is precisely my point. This shouldn't happen. It has to be something happening in the kernel, and maybe something APFS-specific. I only have details from my direct experience in bash, so even though I doubt it has anything to do with bash I framed it that way rather than try to come up with a generalization that might be incorrect. It also happened in the same session with two other tabs, though in a different directory. I do have a copy of each terminal session where I executed various commands (mostly 'ls') to be certain I really was seeing what I thought I was seeing.