holzschu / a-shell

A terminal for iOS, with multiple windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Old .profile content isn't reset

anhlinh123 opened this issue · comments

I'm not sure if I miss anything or this is an actual bug.
On iPhone, I believe forcing close a-shell kills the current session, and then a-shell will start with fresh config + reload .profile.
But let's say .profile has export A=a for the current session, which mean $A is set to a.
If .profile now removes that line, and adds export B=b, forcing restart the session will set both variables.

Yes, environment variables are stored when you leave a-Shell, and restored when you come back, along with the current working directory and screen content. It's a feature (strongly recommended by Apple UX rules, since there's no difference between close app and force-close). It's not just about .profile, but all variables that you set during a session.

That feature can be deactivated using the Settings app: "Keep screen content between sessions" will make each new session restart fresh.

Thanks for your quick response.
There are still some things that are bugging me:

  • I believe the need to start a fresh shell is valid. Doing that by toggling an app setting seems not convenient, as one might need to regularly reset the shell, but still can resume the current work. Probably an explicit command like resetShell is a good idea?
  • As far as I can see, only variables set in .profile are preserved. If I manually run export C=c and force close the app, the new session won't have it set. Is that consistent with the UX you mentioned?

Update on this:
I find .profile's behavior very weird and inconsistent.
After a while playing around with it, mostly updating/creating/removing env vars then forcing restart the app, some of the env vars are updated, while the others stay the same. Sometimes, they even revert to old values.

When the app goes in the background, a-Shell starts saving the environment, so it can restore it later. If you force-quit on an iPhone, you are likely interrupting that process in the middle. That would explain the behaviour you observe. One solution is to not use force-quit.