mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 08:56:20 +00:00
feature(console) change directory and do something after ";, &&, ||"
This commit is contained in:
parent
7ffef6df72
commit
7cf9fad27e
1 changed files with 19 additions and 7 deletions
|
|
@ -281,8 +281,9 @@
|
|||
isVolume = win.isVolume(command),
|
||||
paramDir = Util.rmStrOnce(command, [CD, 'cd']),
|
||||
|
||||
regExpHome = /^~$|^~\s/,
|
||||
isRoot = paramDir === '/',
|
||||
regStrEnd = getRegStrEnd(),
|
||||
regStrHome = '^~$|^~',
|
||||
regExpHome = new RegExp(regStrHome + regStrEnd),
|
||||
isHome = paramDir.match(regExpHome) && !WIN;
|
||||
|
||||
if (isHome) {
|
||||
|
|
@ -293,17 +294,19 @@
|
|||
if (!paramDir && !WIN)
|
||||
paramDir = '.';
|
||||
|
||||
if (!isHome && !isRoot && !isChangeVolume || isVolume) {
|
||||
if (!isHome && !isChangeVolume || isVolume) {
|
||||
paramDir = getFirstWord(paramDir);
|
||||
command = Util.rmStrOnce(command, [
|
||||
CD,
|
||||
paramDir,
|
||||
'\'' + paramDir + '\'',
|
||||
'"' + paramDir + '"',
|
||||
]);
|
||||
|
||||
paramDir = path.join(currDir, paramDir);
|
||||
if (paramDir !== '/')
|
||||
paramDir = path.join(currDir, paramDir);
|
||||
|
||||
command = CD + '"' + paramDir + '" ' + command;
|
||||
command = CD + '"' + paramDir + '" ' + command;
|
||||
}
|
||||
|
||||
exec(command, {cwd: paramDir}, function (error, stdout, stderr) {
|
||||
|
|
@ -327,8 +330,11 @@
|
|||
|
||||
function getFirstWord(str) {
|
||||
var word, result,
|
||||
regExp = /^(.*?)\s/,
|
||||
regExpQuotes = /^"(.*)"\s?/,
|
||||
regStrEnd = getRegStrEnd(),
|
||||
regStr = '^(.*?)',
|
||||
regStrQuotes = '^"(.*)"',
|
||||
regExp = new RegExp(regStr + regStrEnd),
|
||||
regExpQuotes = new RegExp(regStrQuotes + regStrEnd + '?'),
|
||||
is = Util.isString(str);
|
||||
|
||||
if (is) {
|
||||
|
|
@ -348,6 +354,12 @@
|
|||
return word;
|
||||
}
|
||||
|
||||
function getRegStrEnd() {
|
||||
var regStrEnd = '(\\s|\\;|&&|\\|\\|)';
|
||||
|
||||
return regStrEnd;
|
||||
}
|
||||
|
||||
function log(connNum, str, typeParam) {
|
||||
var ret,
|
||||
type = ' ';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue