Score:0

when sourcing a bashrc how to get the line number of the error messages

tr flag

Following this post, I am souring a bashrc file inside the WSL2/Ubuntu by:

source /usr/share/openfoam/etc/bashrc

but I get lots of error messages:

-bash: /usr/share/openfoam/bin/<someFile>: No such file or directory

now I want to know which line(s) of the original bashrc file is causing these errors. I don't want to mess up the script, so preferably if the source command has some options to print out the line numbers of the stream output, or is there a way to activate that generally, that would be the best.

Score:0
tr flag

From here, I realized that the source command does one job, executing the given file in Bash. Therefore, to get the line numbers one can simply do:

bash --debug /path/to/the/file
NotTheDr01ds avatar
vn flag
I agree that it's definitely the best way to get the line numbers, but keep in mind that running a script through `bash /path/to/the/file` is *not* the same as sourcing it. When you `source` a script, the script is processed *inside* the current shell, and can do things like set environment variables. When you run it through the `bash` command, it is run in a new environment, and any changes to variables are lost after that shell exits.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.