升级终端命令的难处: 为什么字符串匹配不起作用

升级终端命令的难处: 为什么字符串匹配不起作用

2026年9月2日1 次浏览来源:Dev.to阅读原文

正文保留英文原文(机翻易破坏代码与排版),标题/摘要已提供中文

1.

The problem: I wanted to auto-grade a terminal task

2.

First attempt: compare the typed command to an expected command as a string — why it broke (infinite commands do the same job)

3.

Second attempt: parse the output with regex — why it broke (different commands, equally valid output)

4.

The fix: check simulated filesystem/process state at the end of the task instead

5.

How I built this in JS (short code sample)

6.

Result: this is how ShellPer's Lab module works, try it here ShellPer On Google Play Store ! 👇🏻

分享