Skip to content

Commit

Permalink
Set os' cwd to bdsh's cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
logandhillon committed Aug 9, 2024
1 parent e08c775 commit 299ad2b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bdsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, stdout: TextIO, stdin: TextIO, **is_ssh: bool):
self.print = lambda s: self.stdout.write(s)
self.readchar = lambda: self.stdin.read(1)
self.is_ssh = is_ssh
self.path = self.get_path("")
self.path = self.get_path()
self.cwd = lambda: os.path.relpath(self.path, root_dir).replace('.', '/', 1)

self.header = f"BadOS Dynamic Shell (v0.1) {'(BadBandSSH)' if is_ssh else ''}{nl}(c) Bad Technologies. All rights reserved.{nl}"
Expand Down Expand Up @@ -69,6 +69,7 @@ def cmd_throw(self, args):
def cmd_go(self, args):
if os.path.exists(path := self.get_path(args[1])):
self.path = path
os.chdir(path)
else:
raise FileNotFoundError(f"{args[1]}: no such file or folder")

Expand Down Expand Up @@ -109,6 +110,7 @@ def get_path(self, *paths: str):
return dir if dir.startswith(root_dir) else root_dir

def start(self):
os.chdir(self.get_path())
self.run_line("ver")

if not os.path.exists(self.get_path()):
Expand Down Expand Up @@ -155,5 +157,7 @@ def start(self):


if __name__ == "__main__":
_cwd = os.getcwd()
bdsh = Shell(sys.stdout, sys.stdin)
bdsh.start()
os.chdir(_cwd)

0 comments on commit 299ad2b

Please sign in to comment.