在 main.py 中添加对 'ls' 和 'll' 命令的支持,默认参数为 '-l'

This commit is contained in:
2025-04-08 08:44:04 +08:00
Unverified
parent 4f83e61552
commit c3d0f3928d

16
main.py
View File

@@ -74,6 +74,22 @@ def pseudo_zsh():
except FileNotFoundError:
print(f"cd: no such file or directory: {args[1]}") # 目录不存在
continue
if args[0] == 'ls':
try:
if len(args) == 1:
args.append('-l') # 默认参数
subprocess.run(['ls'] + args[1:]) # 执行 ls 命令
except FileNotFoundError:
print(f"zsh: command not found: {args[0]}")
if args[0] == 'll':
try:
if len(args) == 1:
args.append('-l') # 默认参数
subprocess.run(['ls'] + args[1:]) # 执行 ll 命令
except FileNotFoundError:
print(f"zsh: command not found: {args[0]}")
# 伪造 sudo 密码输入并记录