diff --git a/client/mysqltest.c b/client/mysqltest.c index 5dd2f5dc65e..a039d970b18 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1367,7 +1367,9 @@ int do_modify_var(struct st_query *query, const char *name, NOTE If mysqltest is executed from cygwin shell, the command will be - executed in cygwin shell. Thus commands like "rm" etc can be used. + executed in the "windows command interpreter" cmd.exe and we prepend "sh" + to make it be executed by cygwins "bash". Thus commands like "rm", + "mkdir" as well as shellscripts can executed by "system" in Windows. */ int do_system(struct st_query *command) @@ -1379,9 +1381,18 @@ int do_system(struct st_query *command) init_dynamic_string(&ds_cmd, 0, strlen(command->first_argument) + 64, 256); +#ifdef __WIN__ + /* Execute the command in "bash", ie. sh -c "" */ + dynstr_append(&ds_cmd, "sh -c \""); +#endif + /* Eval the system command, thus replacing all environment variables */ do_eval(&ds_cmd, command->first_argument, TRUE); +#ifdef __WIN__ + dynstr_append(&ds_cmd, "\""); +#endif + DBUG_PRINT("info", ("running system command '%s' as '%s'", command->first_argument, ds_cmd.str)); if (system(ds_cmd.str)) diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 9008eff6642..b5e05579023 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -830,8 +830,8 @@ DROP TABLE t1, t2; # Bugs #9136, #12917: problems with --defaults-extra-file option # ---system echo "[mysqltest1]" > $MYSQLTEST_VARDIR/tmp/tmp.cnf ---system echo "port=1234" >> $MYSQLTEST_VARDIR/tmp/tmp.cnf +--system echo '[mysqltest1]' > $MYSQLTEST_VARDIR/tmp/tmp.cnf +--system echo 'port=1234' >> $MYSQLTEST_VARDIR/tmp/tmp.cnf --exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 --exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1 --system rm $MYSQLTEST_VARDIR/tmp/tmp.cnf