change for this ugly environment-getting-thing

This commit is contained in:
overflowerror 2013-08-03 16:25:41 +02:00
parent 0874fd7176
commit d75ba36743
4 changed files with 8 additions and 7 deletions

View file

@ -8,7 +8,7 @@ CatClass.prototype.main = function(args) {
this.stream = this.files['stdin']; this.stream = this.files['stdin'];
} else { } else {
this.stream = new AppStream(); this.stream = new AppStream();
var env = Kernel.ProcessManager.processList[this.parentId].Environment; // ugly, change this var env = this.Environment;
var name = args[1]; var name = args[1];
if (name.substring(0, 1) != "/") if (name.substring(0, 1) != "/")
name = env.array['PWD'] + name; name = env.array['PWD'] + name;

View file

@ -3,7 +3,7 @@ var CdClass = function() {
CdClass.prototype = new Process(); CdClass.prototype = new Process();
CdClass.prototype.main = function(args) { CdClass.prototype.main = function(args) {
var stdout = this.files['stdout']; var stdout = this.files['stdout'];
var env = Kernel.ProcessManager.processList[this.parentId].Environment; // ugly, change this var env = this.Environment;
var folder = ""; var folder = "";
if (args.length == 1) { if (args.length == 1) {
folder = env.array['HOME']; folder = env.array['HOME'];
@ -14,16 +14,15 @@ CdClass.prototype.main = function(args) {
folder = env.array['PWD'] + folder; folder = env.array['PWD'] + folder;
if (folder[folder.length - 1] != "/") if (folder[folder.length - 1] != "/")
folder += "/"; folder += "/";
console.log(folder);
folder = Kernel.Filesystem.shortenPath(folder); folder = Kernel.Filesystem.shortenPath(folder);
console.log(folder); if (!folder) {
this.exit(0);
}
var files = Kernel.Filesystem.getDirectory(folder); var files = Kernel.Filesystem.getDirectory(folder);
if (files.error) { if (files.error) {
stdout.write("cd: cannot access " + folder + ": " + files.error + "\n"); stdout.write("cd: cannot access " + folder + ": " + files.error + "\n");
this.exit(2); this.exit(2);
return; // ugly, change this
} }
console.log(folder);
env.array['PWD'] = folder; env.array['PWD'] = folder;
this.exit(0); this.exit(0);
} }

View file

@ -3,7 +3,7 @@ var LsClass = function() {
LsClass.prototype = new Process(); LsClass.prototype = new Process();
LsClass.prototype.main = function(args) { LsClass.prototype.main = function(args) {
var stdout = this.files['stdout']; var stdout = this.files['stdout'];
var env = Kernel.ProcessManager.processList[this.parentId].Environment.array; // ugly, change this var env = this.Environment.array;
var folder = ""; var folder = "";
if (args.length == 1) { if (args.length == 1) {
folder = env['PWD']; folder = env['PWD'];
@ -14,6 +14,7 @@ LsClass.prototype.main = function(args) {
if (files.error) { if (files.error) {
stdout.write("ls: cannot access " + folder + ": " + files.error + "\n"); stdout.write("ls: cannot access " + folder + ": " + files.error + "\n");
this.exit(2); this.exit(2);
return; // ugly, change this
} }
for (var i = 0; i < files.length; i++) { for (var i = 0; i < files.length; i++) {
if (files[i].substring(0, 1) != ".") if (files[i].substring(0, 1) != ".")

View file

@ -213,6 +213,7 @@ WshClass.prototype.parseLine = function() {
s += " for(var i = 0; i < paths.length; i++) {"; s += " for(var i = 0; i < paths.length; i++) {";
s += " prog.files[paths[i][0]] = Kernel.Filesystem.getFile(paths[i][1]);"; s += " prog.files[paths[i][0]] = Kernel.Filesystem.getFile(paths[i][1]);";
s += " }"; s += " }";
s += " prog.Environment = Kernel.ProcessManager.processList[" + this.pid + "].Environment;";
s += " Kernel.ProcessManager.add(prog);"; s += " Kernel.ProcessManager.add(prog);";
s += " console.log(\"wsh: start command '" + file + "'...\");"; s += " console.log(\"wsh: start command '" + file + "'...\");";
s += " try {"; s += " try {";