Nitpicking the shell history scene in ‘Tron: Legacy’

Nitpicking the shell history scene in ‘Tron: Legacy’

细究《创:战纪》中的 Shell 历史记录场景

[Simon Tatham, 2026-05-28]

Introduction

引言

In the 2010 film Tron: Legacy, there’s a scene where the main character Sam Flynn sits down at a computer in his father’s study, and types some commands to try to figure out what Flynn senior had last been working on, before mysteriously disappearing. When I first watched the film (conveniently, already on DVD), I paused it so that I could have a close look at the text on the computer screen. What can I say? I’m that kind of geek. 在 2010 年的电影《创:战纪》(Tron: Legacy)中,有一个场景:主角萨姆·弗林(Sam Flynn)坐在他父亲书房的电脑前,输入了一些命令,试图找出他父亲在神秘失踪前最后在处理什么工作。当我第一次看这部电影时(很方便,当时已经是 DVD 版本了),我按下了暂停键,以便仔细观察电脑屏幕上的文字。我能说什么呢?我就是那种极客。

The Tron film series as a whole is based on some completely ludicrous premises about how computers work. So I wasn’t expecting realism; more likely I thought it would be hilarious fake-computerese nonsense made up entirely by movie people. In fact I saw an almost plausible Unix shell transcript, whose contents made sense in the context of the film plot – albeit with a couple of nits that jumped out at me immediately. 整个《创》系列电影都是基于一些关于计算机如何工作的极其荒谬的前提。所以我并没有期待什么现实感;我更倾向于认为这会是电影制作人员完全编造出来的、滑稽的伪计算机术语。但事实上,我看到了一段几乎可信的 Unix Shell 记录,其内容在电影情节的背景下是说得通的——尽管有几个小瑕疵让我一眼就注意到了。

This year, I remembered that scene, and thought it might make a good learning exercise for a junior colleague: let’s look at that still image together and see how much we can understand about it. Can we find all the outright errors? Disregarding things we’ve definitely decided are errors, what can we infer from the rest of it about the computer system and what the Flynns (both of them) are doing with it? 今年,我想起了那个场景,觉得这可能是一个给初级同事进行学习练习的好素材:让我们一起看看那张剧照,看看我们能从中理解多少。我们能找出所有明显的错误吗?撇开那些我们已经确定是错误的地方,我们能从剩下的部分推断出关于这个计算机系统以及弗林父子(他们两人)正在用它做什么吗?

I hoped this might be fun, interesting, and/or educational. It succeeded at all three, beyond my hopes! Instead of the half hour I’d guessed, we spent a whole day on it, on and off (exchanging Slack messages, in between other work), and squeezed a lot more juice out of it than I’d realised was there to be squozen. By the end of the exercise, I’d decided one of my own initial complaints was wrong (but found another to replace it), and I’d learned some new things myself. And I ended up more impressed than I’d started, with whoever constructed that screenshot. So, since it ended up being that much fun, here’s a writeup, so that if you’re the same kind of geek as me, you can share the enjoyment! 我希望这既有趣、有意义,又能起到教育作用。它在这三方面都取得了成功,超出了我的预期!我们原本以为只需半小时,结果断断续续花了一整天(在处理其他工作之余交换 Slack 消息),从中挖掘出的信息远比我预想的要多。练习结束时,我推翻了自己最初的一个抱怨(但又发现了另一个来代替它),我自己也学到了一些新东西。最终,我对制作那张截图的人的敬佩程度比开始时更高了。所以,既然它最终变得如此有趣,我写下了这篇文章,这样如果你和我一样是那种极客,也可以分享这份乐趣!

Spoilers

剧透警告

This article will include a minor spoiler for a thing that happens in the film. But it won’t be anything you couldn’t easily have guessed was going to appear somewhere in the film, just from having watched the original 1982 film that this is a sequel to, Tron itself. In any case, even Tron: Legacy is 16 years old by now and another Tron film has come out since, so if you care about spoilers for it at all, you’ve probably already seen it. 本文将包含一个关于电影情节的小剧透。但这并不是你无法轻易猜到的内容,只要看过 1982 年的原版电影《电子世界争霸战》(Tron,即本片的续作对象),你就能猜到它会出现在电影的某个地方。无论如何,《创:战纪》现在已经上映 16 年了,之后还有另一部《创》系列电影上映,所以如果你真的在意剧透,你可能早就看过了。

More to the point, when I set this exercise to my colleague, it was intended as an educational puzzle – the point was to work out the answers, not just hear them in the form of a lecture. So I’m going to take care not to spoil that puzzle. In this article I’ll present all the answers I have, but they’re below a <details> fold, so you can examine the transcript yourself before clicking through, and see how much you can get from it yourself. 更重要的是,当我给同事布置这个练习时,它是作为一道教育谜题设计的——重点是自己找出答案,而不是仅仅通过讲座来听取答案。所以我将小心翼翼地不去破坏这个谜题。在本文中,我将提供我所有的答案,但它们被放在了 <details> 折叠标签下,这样你可以在点击查看之前先自行研究那段记录,看看你能从中解读出多少信息。

The screenshot

截图

Of course I have to start by showing a still image from the film. […] The smears in front of the text, and the uneven background colour behind it, are because the screen is a reflective desk surface which had a thick layer of dust all over it until a moment ago; just before Sam sat down, we saw him wipe some of the dust off. When Sam arrived, the main shell window on the right was empty. Everything shown in it here is commands he typed himself just now, and the computer’s responses to those commands. 当然,我必须从展示电影中的一张剧照开始。[…] 文字前的污迹和背后不均匀的背景颜色,是因为屏幕是一个反光的桌面表面,刚才上面还覆盖着厚厚的一层灰尘;在萨姆坐下之前,我们看到他擦掉了一些灰尘。当萨姆到达时,右侧的主 Shell 窗口是空的。这里显示的所有内容都是他刚才自己输入的命令,以及计算机对这些命令的响应。

Text transcript

文本记录

I’ve typed this out by hand so that you don’t have to: here’s a text transcript of the session in that main shell window. 我已经手动将其录入,这样你就不用费心了:以下是该主 Shell 窗口中会话的文本记录。

$ whoami
flynn
$ uname -a
SolarOS 4.0.1 Generic_50203-02 sun4m i386 Unknown.Unknown
$ login -n root
Login incorrect
login: backdoor
No home directory specified in password file!
Logging in with home=/
# bin/history
488 cd /opt/LLL/controller/laser/
489 vi LLLSDLaserControl.c
490 make
491 make install
492 ./sanity_check
493 ./configure -o test.cfg
494 vi test.cfg
495 vi ~/last_will_and_testament.txt
496 cat /proc/meminfo
497 ps -a -x -u
498 kill -9 2207
499 kill 2208
500 ps -a -x -u
501 touch /opt/LLL/run/ok
502 LLLSDLaserControl -ok 1
#

What can we observe from this screenshot?

我们能从这张截图中观察到什么?

If you’re up for trying this exercise yourself, have a good look at the image above, and see what you can see. When you’re ready, click through the cut below, and you’ll see a list of topics to think about. If those give you useful hints, you’ve got another chance to think harder about each one, before you open each topic in turn to see the thoughts we had about it. 如果你想亲自尝试这个练习,请仔细观察上面的图片,看看你能发现什么。当你准备好后,点击下方的折叠内容,你将看到一系列值得思考的主题。如果这些主题为你提供了有用的线索,你还有机会在依次打开每个主题查看我们的想法之前,对每一个问题进行更深入的思考。

Topic list

主题列表

The command that prints the shell history 打印 Shell 历史记录的命令

This was the very first thing that jumped out at me when I first watched this film and paused the DVD. Sam requests the shell history by running bin/history instead of just history. Why? I can’t see any possible way that makes sense on real Unix. Shell history is stored in data structures inside the shell process itself, so the history command must be a shell builtin, in order to read out those structures. Even if you only wanted to read out the version of the history stored in a disk file, the… 这是我第一次看这部电影并暂停 DVD 时,第一个引起我注意的地方。萨姆通过运行 bin/history 而不是直接运行 history 来请求 Shell 历史记录。为什么?在真正的 Unix 系统中,我想不出任何合理的解释。Shell 历史记录存储在 Shell 进程内部的数据结构中,因此 history 命令必须是 Shell 的内置命令,才能读取这些结构。即使你只是想读取存储在磁盘文件中的历史记录版本,……