I'm trying to add a function to my .bashrc, but I'm hitting a wall with errors related to quotes. The terminal returns these messages: -bash: .bashrc: line 142: unexpected EOF while looking for matching `'' and -bash: .bashrc: line 145: syntax error: unexpected end of file. Here's the function I'm attempting to add:
```bash
dwdb() {
local query="SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME;"
sqlcmd -S link -d table -U user -P 'password' -C -Q "$query"
}
```
5 Answers
It looks like you're facing an issue with quote matching in your script. The error you're getting suggests that there might be a missing quote earlier in your .bashrc file, potentially before your function. Check the lines above line 140 to see if any quotes are unclosed.
Make sure you're formatting your code properly. Sometimes, misalignment or improper record of quotes can lead to these errors. Also, the error may stem from a function defined earlier in the script that has some sort of quote mismatch.
Have you tried using `shellcheck`? It's a great tool for detecting syntax errors in your shell scripts. It might point you directly to where the issue lies.
It seems like your function might need a declaration. Try redefining your function like:
```bash
function dwdb() {
local query="SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME;"
sqlcmd -S link -d table -U user -P 'password' -C -Q "$query"
}
``` This could help clarify the syntax.
You're right about `unexpected EOF while looking for matching `''`—it's indicating a problem with quotes. Check for any stray single quotes or backticks that might be left unclosed in your .bashrc file.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically