lots of errors after sudo bash in terminal

Solution 1:

For cases like this with a more detailed dot file, to get a root shell, I would use

sudo -s

If that works, you might add one line to your .bashrc if you like a more detailed prompt: https://superuser.com/questions/866269/use-sudo-s-but-show-current-folder-name

I don’t and want the root prompt to be very different so I know I’m root and not my normal user as that saves pain for me if I forget to get out of root as soon as possible.

If you want an excellent tutorial on root shell for macOS - see https://scriptingosx.com/2018/04/demystifying-root-on-macos-part-2-the-sudo-command/

Solution 2:

Here was the problem: I had saved the file as a windows file.

The clue was a \r following the file name when I added ls -l /usr/bin/id command to my .bashrc script see the command permissions.

ls: /usr/bin/id\r: No such file or directory

Here was the status bar from textwrangler. Notice .bashrc is to be saved as a windows file. enter image description here