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:
chmod 0666 /tmp/this-is-my-environment
On Thu, Nov 11, 2021 at 3:57 PM Huji Lee <firstname.lastname@example.org> wrote:
How are you calling the .sh file? It doesn't have a shebang so I'mguessing you are doing $ sh daily.shIn 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 ispart of POSIX  and is implemented in dash,`source` is also a zsh builtin  so I have no idea how it's breakingfor you. Somehow your scripts are being run by dash if you have `execzsh`, but since I don't know how you are invoking the scripts I cannottrace the code.YiFei Zhu https://man7.org/linux/man-pages/man1/dot.1p.html https://sourceforge.net/p/zsh/code/ci/master/tree/Src/builtin.c#l116
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,
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._______________________________________________Cloud mailing list -- email@example.comList information: https://lists.wikimedia.org/postorius/lists/cloud.lists.wikimedia.org/
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:
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 -- firstname.lastname@example.org
List information: https://lists.wikimedia.org/postorius/lists/cloud.lists.wikimedia.org/