-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_nksh.py
More file actions
42 lines (36 loc) · 1.04 KB
/
ex_nksh.py
File metadata and controls
42 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from stdio import *
import os
import readline
debug = True
while True:
# Get current working directory
cwd = pya<"os.getcwd "
# Prompt user for input
inp = i < f'nksh:{cwd} $ '
command = types.str_ < inp
if debug:
p < f"Command entered: {command}"
try:
# Check if the command starts with 'cd'
a = exe < f"command.strip{call}"
cdcmd=pya<'a.startswith \'cd\''
if debug:
p < f"Is 'cd' command: {cdcmd}"
if cdcmd:
directory = exe<"types.str_<command[3:].strip"+call
try:
p < 'cd called'
pya<f"os.chdir '{directory}'"
except Exception as e:
p < f"cd error: {e}"
elif command:
# Execute other shell commands
cmd < command
except EOFError:
pya<'sys.exit 0'
except Exception as e:
# Handle other errors
p < f"error: {e}"
except KeyboardInterrupt:
# Ignore keyboard interrupts
pass