Permalink
Browse files

Merge pull request #659 from yksoft1/cmdline-bat-fix

Fix parsing .BAT filenames, which not in current directory, in command line.
  • Loading branch information...
joncampbell123 committed Apr 9, 2018
2 parents 8b50581 + ce30e77 commit e57cbda3eb5ea6ad4e622c3d57e9bd486088fa8a
Showing with 15 additions and 7 deletions.
  1. +15 −7 src/shell/shell.cpp
View
@@ -396,20 +396,28 @@ class AUTOEXEC:public Module_base {
if (!control->auto_bat_additional.empty()) {
std::string cmd;
cmd += "@mount c: . -q\n";
cmd += "@c:\n";
cmd += "@cd \\\n";
for (unsigned int i=0;i<control->auto_bat_additional.size();i++) {
std::string batname;
/* NTS: this code might have problems with DBCS filenames - yksoft1 */
size_t pos = control->auto_bat_additional[i].find_last_of(CROSS_FILESPLIT);
if(pos == std::string::npos) { //Only a filename, mount current directory
batname = control->auto_bat_additional[i];
cmd += "@mount c: . -q\n";
} else { //Parse the path of .BAT file
std::string batpath = control->auto_bat_additional[i].substr(0,pos+1);
batname = control->auto_bat_additional[i].substr(pos+1);
cmd += "@mount c: " + batpath + " -q\n";
}
cmd += "@c:\n";
cmd += "@cd \\\n";
/* NTS: "CALL" does not support quoting the filename.
* This will break if the batch file name has spaces in it. */
cmd += "@CALL ";
cmd += control->auto_bat_additional[i];
cmd += batname;
cmd += "\n";
cmd += "@mount -u c: -q\n";
}
cmd += "@mount -u c: -q\n";
autoexec_auto_bat.Install(cmd);
}

0 comments on commit e57cbda

Please sign in to comment.