I have installed Xubuntu 16.04 and mysql 5.7 server.
I create simple script with name mysql-wrapper
:
#!/bin/bash
mysql -u myuser -pmypwd mydatabase --table $*
Now I run command and it execute successfully:
mysql-wrapper -e "STATUS"
Then I try run next command (with space):
mysql-wrapper -e "SHOW TABLES"
I get problem: mysql print me help for commands, like I run mysql with illegal command.
How I can solve my issue? Or may be better use alias?
In ordinary usage, you shouldn't have any reason for using a plain
$*
. You should always be using"$@"
(note that the quotes are included):Only with
"$@"
will your script arguments pe passed as-is to the command, this is safe from field splitting and globbing.To see the difference, run a script containing
with various arguments.