2

I have a small distro (not busybox) that uses ash, and I am not sure how the dot file structure is handled. .ashrc doesnt seem to be picked up nor I see a .bash_profile analog. Is there a default convention for shell startup file?

  • 1
    Have you considered reading the shell's man page? It's documented there, in the Invocation section. – Charles Duffy Nov 10 '16 at 22:44
  • (...it's also not really a software-development-specific question, and so not particularly on-topic on StackOverflow; Unix SE or SuperUser would be a better fit). – Charles Duffy Nov 10 '16 at 22:47

1 Answers1

3

This is covered in the Invocation section of the man page.

~/.profile is read for login shells. For non-login interactive shells to read a dotfile at startup, you need to in your environment (ie. set by .profile) specify the name of a file to read in ENV. Thus, the following will ensure that PS1 is updated in every interactive shell created after the next login session:

$ echo 'export ENV=$HOME/.rc' >>"$HOME/.profile"
$ echo 'PS1="> "' >>"$HOME/.rc"
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • Hello Charles, what is the solution for non interactive non login shell(shell script), context :- I want my ansible task to pick up this environment variable – itsjwala Apr 07 '20 at 11:51
  • 1
    @JigarWala, I advise against that. Better to create an ansible variable (which you can do with the stdout of a shell or command module invocation, potentially one that inspects dotfile contents if that's what you really need) and set your per-task environment variables from it, as documented at https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html – Charles Duffy Apr 07 '20 at 12:42