Right, but only if it's you default shell. If you just runit will be sourced in every interactive shell you launch.
sh
it won't use ~/.profile and thus won't source ~/.shrc.I have been using zsh [...] Any /bin/sh and most /bin/bash scripts should work in it unchanged.
Figuring out how each different shell processes "dotfiles" is arcane, at best.
And bash(1) is definitely the most arcane of all.
[ -f ~/echodot] && echo .profile sourced # put the name of each file instead
There are various options to control compatibility. Though I usually stick to /bin/sh for scripts.There is a difference in default behavior when word splitting, though. Complicated bourne shell code will not generally run in zsh.
You can always do "ktrace -di <shell> ..." and then "kdump | grep NAMI" to see what files <shell> looks for.Create all the dotfiles and put this as the first line in each:
Code:[ -f ~/echodot] && echo .profile sourced # put the name of each file instead
Then, later, you can do `touch ~/echodot` and it will tell you which file is executed when you start shells.
Or just read the manual page.You can always do "ktrace -di <shell> ..." and then "kdump | grep NAMI" to see what files <shell> looks for.
Invocation
If no arguments are present and if the standard input of the shell is
connected to a terminal (or if the -i option is set), the shell is
considered an interactive shell. An interactive shell generally prompts
before each command and handles programming and command errors
differently (as described below). When first starting, the shell
inspects argument 0, and if it begins with a dash (‘-’), the shell is
also considered a login shell. This is normally done automatically by
the system when the user first logs in. A login shell first reads
commands from the files /etc/profile and then .profile in a user's home
directory, if they exist. If the environment variable ENV is set on
entry to a shell, or is set in the .profile of a login shell, the shell
then subjects its value to parameter expansion and arithmetic expansion
and reads commands from the named file. Therefore, a user should place
commands that are to be executed only at login time in the .profile file,
and commands that are executed for every shell inside the ENV file. The
user can set the ENV variable to some file by placing the following line
in the file .profile in the home directory, substituting for .shrc the
filename desired:
ENV=$HOME/.shrc; export ENV
The first non-option argument specified on the command line will be
treated as the name of a file from which to read commands (a shell
script), and the remaining arguments are set as the positional parameters
of the shell ($1, $2, etc.). Otherwise, the shell reads commands from
its standard input.
Unlike older versions of sh the ENV script is only sourced on invocation
of interactive shells. This closes a well-known, and sometimes easily
exploitable security hole related to poorly thought out ENV scripts.
I don't think that interactive = login. At least with /bin/sh this is not true. When you switch to it by runningMost, if not all, shells have different behaviors when it comes to interactive vs. non-interactive and login vs. non-login.
sh
from within /bin/csh or /usr/local/bin/bash it ignores ~/.profile and ~/.shrc.Never said it was. I said there's a difference between interactive vs non-interactive AND login vs. non-login. You can have 4 different situations all behaving differently. Interactive non-login, interactive login, non-interactive non-login, and last but not least non-interactive login.I don't think that interactive = login.
I usw zsh Myself. But man, its manpages are not written for normal people ??read its man page(s)!