-
- elif command == "help" and len(command_args) > 1:
- help_topic = command_args.split(" ")[0]
- if help_topic == "sry":
- print("SRY\n\tEaster Egg. Just try it!")
- elif help_topic == "two":
- print("TWO\n\tTime Wasting Option")
- print("\tDon't conflate TWO with TSO in the OS/360")
- print("\tfamily of mainframe systems!")
- elif help_topic in ("shutdown", "poweroff", "halt"):
- print("shutdown/poweroff/halt")
- print("\tRunning them is interpreted as an act of violence")
- print("\tagainst the Dalek!")
- else:
- print(help_topic)
- print("\tFAKENEWS!")
-
- elif command == "whoami":
- if not env.getUser() in ["doctor", "doctorwho", "doctor_who"]:
- print(env.getUser())
- else:
- #print("I am the Doctor!")
- print(env.getName())
- print("")
- print("I should behave politely, so maybe excuse for")
- print("future mistakes with \"sry\" (Yes, an easter egg!)")
- print("")
-
- elif command == "shutdown" or command == "poweroff" or command == "halt":
- print("Exterminate!")
- print("Exterminate!".upper())
- sys.exit(0)
-
- elif command == "id":
- print("uid=42(" + env.getUser() + ") gid=100(users) groups=42(" + env.getUser() + "),9999(telnet)")
-
- elif command == "hostname":
- print(env.getNode())
-
- elif command == "pwd":
- #print("/usr/home/"+getuser())
- print(env.getCurrentDir(True))
-
- elif command == "ls" or command == "dir":
- #print("A: TARDIS ZIP : DALEK EXE")
- #print("A: CLARA DOC : ASHILDR GIF")
- _dir = env.getDirListing()
- for _entry in _dir:
- print(" " + env.getCurrentDir()[:2] + " " + _entry)
-
- elif command == "cat" or command == "type":
- # DEBUG:
- #print("CMD = \"" + command + "\"")
- #print("ARGS = \"" + command_args + "\"")
-
- filename = command_args.upper()
- print(env.getFileContents(filename))
-
- elif command == "uname":
- print(env.getUName())
-
- elif command == "clear":
- # clear screen
- ret_code = os.system("clear")
-
- elif command == "sry" or command == "bofh":
- # BOFH excuse
- print("<BOFH> "+bbs.bofh.get_excuse())
-
- elif len(command) == 2 and command[1] == ":":
- # Change drive/working directory
- env.setCurrentDir(command.upper())
-
- #elif not command in commands_allowed:
- # print("-minishell: "+command.split(" ")[0]+": Command not found.")
- elif len(command) > 0:
- print("TWO: "+command.split(" ")[0]+": Command not found.")
-
- except EOFError:
- print("<EOF>")
-
- print("Good bye.")
+
+ elif command == "help" and len(command_args) > 1:
+ help_topic = command_args.split(" ")[0]
+ if help_topic == "sry":
+ print("SRY\n\tEaster Egg. Just try it!")
+ elif help_topic == "two":
+ print("TWO\n\tTime Wasting Option")
+ print("\tDon't conflate TWO with TSO in the OS/360")
+ print("\tfamily of mainframe systems!")
+ elif help_topic in ("shutdown", "poweroff", "halt"):
+ print("shutdown/poweroff/halt")
+ print("\tRunning them is interpreted as an act of violence")
+ print("\tagainst the Dalek!")
+ else:
+ print(help_topic)
+ print("\tFAKENEWS!")
+
+ elif command == "whoami":
+ if not env.getUser() in ["doctor", "doctorwho", "doctor_who"]:
+ print(env.getUser())
+ else:
+ #print("I am the Doctor!")
+ print(env.getName())
+ print("")
+ print("I should behave politely, so maybe excuse for")
+ print("future mistakes with \"sry\" (Yes, an easter egg!)")
+ print("")
+
+ elif command == "shutdown" or command == "poweroff" or command == "halt":
+ print("Exterminate!")
+ print("Exterminate!".upper())
+ sys.exit(0)
+
+ elif command == "id":
+ print("uid=42(" + env.getUser() + ") gid=100(users) groups=42(" + env.getUser() + "),9999(telnet)")
+
+ elif command == "hostname":
+ print(env.getNode())
+
+ elif command == "pwd":
+ print(env.getCurrentDir(True))
+
+ elif command == "ls" or command == "dir":
+ _dir = env.getDirListing()
+ for _entry in _dir:
+ print(" " + env.getCurrentDir()[:2] + " " + _entry)
+
+ elif command == "cat" or command == "type":
+ filename = command_args.upper()
+ try:
+ print(env.getFileContents(filename))
+ except FileNotFoundError:
+ full_filename = env.getCurrentDir() + filename
+ print("TWO: [ERROR] File not found: " + full_filename)
+
+ elif command == "uname":
+ print(env.getUName())
+
+ elif command == "clear":
+ # clear screen
+ ret_code = os.system("clear")
+
+ elif command == "sry" or command == "bofh":
+ # BOFH excuse
+ print("<BOFH> "+bbs.bofh.get_excuse())
+
+ elif len(command) == 2 and command[1] == ":":
+ # Change drive/working directory
+ try:
+ env.setCurrentDir(command.upper())
+ except FileNotFoundError:
+ print("TWO: [ERROR] Drive " + command.upper() + " does not exist!")
+
+ elif len(command) > 0:
+ print("TWO: "+command.split(" ")[0]+": Command not found.")
+
+ except EOFError:
+ print("<EOF>")
+
+ print("Good bye.")
+