Those are both great ideas! Let me explore more.

Just briefly to respond to YiFei: I call the scripts from cronjobs (see here) which makes me think your intuition is right and they are being called by / and not by my shell. Is there a way that I can tell, from within a script, how it was called?

On Fri, Nov 12, 2021 at 1:16 PM Roy Smith <> wrote:
When I can't figure out WTF is going on with a shell script, I put something like this in the front of it:

/usr/bin/env > /tmp/this-is-my-environment

No matter how screwed up your env, path, choice of shell, output redirection, etc are, that's pretty much guaranteed to dump some useful information into someplace where you can find it.  The likely suspects are $SHELL, $PATH, $PWD, $USER.

In truly bizarre cases, there might be some permission problem, which you can solve with:

touch /tmp/this-is-my-environment
chmod 0666 /tmp/this-is-my-environment

On Nov 12, 2021, at 10:21 AM, YiFei Zhu <> wrote:

On Thu, Nov 11, 2021 at 3:57 PM Huji Lee <> wrote:

Hi all,

Starting Nov 7, a number of the jobs I would run through Toolforge grid have stopped working. Each job consists of a .sh file like this on the first line of which I use the source command to activate a python virtual environment. When I run source by hand, subsequent lines work. But when I call the .sh file and it tries to run the source command, I get a "source: not found" message,

How are you calling the .sh file? It doesn't have a shebang so I'm
guessing you are doing
 $ sh
In that case, invoke it with `bash`/ `zsh` instead of `sh`, since `sh`
is dash which does not have the not have the source command.
Alternatively you can use a dot instead of `source` which actually is
part of POSIX [1] and is implemented in dash,

`source` is also a zsh builtin [2] so I have no idea how it's breaking
for you. Somehow your scripts are being run by dash if you have `exec
zsh`, but since I don't know how you are invoking the scripts I cannot
trace the code.

YiFei Zhu


the virtual environment does not get activated and indeed running which python returns /usr/bin/python which is bad. All my scripts depend on pip packages that are installed in the virtual env and not available with the system python.

The main thing I did on Nov 7 was to add a line at the end of my too's account's .bash_profile as below:

exec zsh

This is because when I manually log into toolforge, I would like zsh to be my shell, and since tool accounts don't support chsh, I thought executing zsh directly from bash would be okay. But apparently, that now breaks the source command somehow.

So I wonder:

(a) Is there a way to properly change the default shell of tool accounts?
(b) Is there a way to make source work under zsh?

Importantly, I know the problem is with exec zsh because once I removed it and logged out and back in, all scripts worked correctly.

Cloud mailing list --
List information:
Cloud mailing list --
List information:

Cloud mailing list --
List information: