[GH-ISSUE #22] Run shell as a login shell? #620

Closed
opened 2026-03-15 03:37:44 +03:00 by kerem · 3 comments
Owner

Originally created by @ku1ik on GitHub (Oct 11, 2012).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/22

I noticed on many asciicasts that people explicitly source .bash_profile to get their colored prompt, functions and other handy stuff. Some people even get errors printed because their prompt uses some functions that they have defined in .bash_profile (prompt like other ENV variables gets inherited but functions not).

This is because recorder runs user's shell as interactive shell, but not as login shell.
Some terminal emulators run shell as login shell (with "-l" option), some not.
Recorder just does equivalent of exec $SHELL which translates to exec /bin/bash or exec /bin/zsh.

If there's a way in python script to check if the current shell in which it operates is a login shell we could use this information when spawning new inner shell. Getting the full command that was run to spawn user's current shell would also be helpfull.

Originally created by @ku1ik on GitHub (Oct 11, 2012). Original GitHub issue: https://github.com/asciinema/asciinema/issues/22 I noticed on many asciicasts that people explicitly source .bash_profile to get their colored prompt, functions and other handy stuff. Some people even get errors printed because their prompt uses some functions that they have defined in .bash_profile (prompt like other ENV variables gets inherited but functions not). This is because recorder runs user's shell as interactive shell, but not as login shell. Some terminal emulators run shell as login shell (with "-l" option), some not. Recorder just does equivalent of `exec $SHELL` which translates to `exec /bin/bash` or `exec /bin/zsh`. If there's a way in python script to check if the current shell in which it operates is a login shell we could use this information when spawning new inner shell. Getting the full command that was run to spawn user's current shell would also be helpfull.
kerem closed this issue 2026-03-15 03:37:49 +03:00
Author
Owner
<!-- gh-comment-id:27155863 --> @ku1ik commented on GitHub (Oct 26, 2013): Some resources: - http://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch - http://www.linuxquestions.org/questions/programming-9/how-to-check-in-a-script-whether-the-shell-is-login-or-non-login-360629/
Author
Owner

@prologic commented on GitHub (Mar 24, 2014):

It's trivial enough to simply pass /bin/bash -l as the command to run through ascinemma rec <command> -- I don't think asciinema needs to care about this per say.

<!-- gh-comment-id:38411795 --> @prologic commented on GitHub (Mar 24, 2014): It's trivial enough to simply pass `/bin/bash -l` as the command to run through `ascinemma rec <command>` -- I don't think asciinema needs to care about this per say.
Author
Owner

@zenglian commented on GitHub (Aug 16, 2018):

No no, not only simply pass /bin/bash -l, there are more steps in my case and I do not want to record those "init" steps.

<!-- gh-comment-id:413480085 --> @zenglian commented on GitHub (Aug 16, 2018): No no, not only simply pass `/bin/bash -l`, there are more steps in my case and I do not want to record those "init" steps.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asciinema#620
No description provided.