Skip to content

Commit

Permalink
Patched xsh and posix to allow absolute binary paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkie committed Mar 11, 2011
1 parent e6b53bd commit 6bf9af9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 10 additions & 1 deletion app/d/posix/posix.d
Expand Up @@ -22,6 +22,15 @@ void main(char[][] argv){
MinFS.initialize();
MessageInAbottle* bottle = MessageInAbottle.getMyBottle();

int last_slash = 0;
foreach(idx, chr; argv[0]) {
if (chr == '/') {
last_slash = idx+1;
}
}

argv[0] = argv[0][last_slash..$];

switch(argv[0]){
case "cat":
if(argv.length < 2){
Expand Down Expand Up @@ -193,4 +202,4 @@ void main(char[][] argv){
}

//return 0;
}
}
10 changes: 8 additions & 2 deletions app/d/xsh/xsh.d
Expand Up @@ -228,19 +228,25 @@ void interpret(char[] str) {
bool fallback = true;
File f;

uint idx;

if(arguments[0][0] != '/'){
uint len = arguments[0].length < pathName.length - pathNameLength ? arguments[0].length : pathName.length - pathNameLength;
char[] testPathName = pathName[0..(pathNameLength+len)];

testPathName[pathNameLength..(pathNameLength+len)] = arguments[0];

uint idx;

if(testPathName == MinFS.findPrefix(testPathName, idx)){
f = MinFS.open(testPathName, AccessMode.Writable);
fallback = false;
}
}
else {
if(arguments[0] == MinFS.findPrefix(arguments[0], idx)){
f = MinFS.open(arguments[0], AccessMode.Writable);
fallback = false;
}
}

if(fallback){
f = MinFS.open("/binaries/posix", AccessMode.Writable);
Expand Down

0 comments on commit 6bf9af9

Please sign in to comment.