I'm trying to write a bash function in .bash_profile with a parameter that will run a script on my sql and test it, but I get the following error when trying to invoke it:
$ sqltest() ~/Downloads/hw5-2.sql
-bash: syntax error near unexpected token `~/Downloads/hw5-2.sql`
The parameter is the file path. What I have right now (also have tried "$1" w/o quotes):
sqltest() { java -cp h2-1.4.200.jar org.h2.tools.RunScript -checkResults -url jdbc:h2:mem:test -script "$1" -continueOnError ; }
set -xto enable trace logging, reproducing the error, and showing us how you did it with a transcript including both the command you ran and the exact text that resulted (up to and including the error message itself; any trace logs that relate to printing your prompt or other such local hooks don't need to be included)."$1"inside quotes is correct).sqltest() ~/Downloads/hw5-2.sqlsqltest ~/Downloads/hw5-2.sql. The()is not part of the function name.~works fine. It would be a problem if they were runningsqltest "~/Downloads/hw5-2.sql", but they aren't.