Please consider the following org-mode snippet containing code to call "show tables" on a particular database via a sql code block and to dump out the database via mysqldump using an sh code block
*** Database :PROPERTIES: :header-args: :engine "mysql" :dbuser "user" :dbpassword "password" :dbhost "127.0.0.1" :database "mydb" :var dbuser="user" :var dbpassword="password" :var dbhost="127.0.0.1" :var database="mydb" :END: **** Test connectivity #+begin_src sql show tables; #+end_src #+RESULTS: **** Dump schema #+begin_src sh echo mysqldump -u $dbuser -p $dbpassword -h $dbhost $database #+end_src #+RESULTS: : mysqldump -u user^M^M -p password^M^M -h 127.0.0.1^M^M mydb
You will note that the line that is echoed contains spurious whitespace (line ends by the look of it).
Why is this and how can I make it go away?
If I remove the echo from the sh code block then I get the following error:
mysqldump: Got error: 2005: "Unknown MySQL server host '127.0.0.1^M^M' (8)" when trying to connect
So the whitespace is really there. I am running GNU Emacs 188.8.131.52 (x86_64-w64-mingw32) of 2016-05-26 on Windows 10. So it might be a Windows problem - haven't tried it on Linux yet, will do that when I get home from work.
For bonus marks, can someone tell me how to refactor the header_args so that I don't have to declare everything twice (once for SQL language specific headers and once for code block variables)?
Let me know what additional information I should provide as this is my first post.