I am creating a little automated setup script that will modify /etc/profile
and $HOME/.profile
if some paths are not exported. Then, I'd like to reload these automatically.
I have read that source
does this, so I fired up my terminal and entered:
source /etc/profile
source ~/.profile
From the terminal, it didn't output any error.
However, putting these two commands inside the Bash script results in source: not found
.
- How can I be sure that the script is executed by Bash, even if
#!/bin/sh
is specified (apparently, it does not guarantee it)? - Why would it say that these two sources cannot be found when they are unmistakably there?
.
and sh supportssource
, but that edit was wrong and it has since been rolled back. The reverse is true: csh and tcsh supportsource
, POSIX shells (sh) support.
, and some POSIX-style shells (like bash) support both. I'm mentioning this because you had approved the edit and might otherwise wonder why it was rolled back. If you really want to say what the edit said, you can roll back the rollback--though that would make this answer wrong. (If you want this post to be more detailed, I think it would be better to do a new edit.) – Eliah Kagan Dec 06 '19 at 17:29. ./filename
instead of just. filename
– knocte Jan 07 '23 at 08:46