Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2018-08-16 17:18:21 +08:00
commit 13260c9bda
9 changed files with 505 additions and 610 deletions

View File

@ -5,15 +5,16 @@ Linux 下如何通过两个或多个输出设备播放声音
在 Linux 上处理音频是一件很痛苦的事情。Pulseaudio 的出现则是利弊参半。虽然有些事情 Pluseaudio 能够做的更好,但有些事情则反而变得更复杂了。处理音频的输出就是这么一件事情。
如果你想要在 Linux PC 上启用多个音频输出,你只需要利用一个简单的工具就能在一个虚拟界面上启用另一个发音设备。这比看起来要简单的多。
如果你想要在 Linux PC 上启用多个音频输出,你只需要利用一个简单的工具就能在一个虚拟j接口上启用另一个声音设备。这比看起来要简单的多。
你可能会好奇为什么要这么做,一个很常见的情况是用电脑在电视上播放视频,你可以同时使用电脑和电视上的扬声器。
### 安装 Paprefs
实现从多个来源启用音频播放的最简单的方法是是一款名为 "paprefs" 的简单图形化工具。它是 PulseAudio Preferences 的缩写。
实现从多个来源启用音频播放的最简单的方法是是一款名为 “paprefs” 的简单图形化工具。它是 PulseAudio Preferences 的缩写。
该软件包含在 Ubuntu 仓库中,可以直接用 apt 来进行安装。
```
sudo apt install paprefs
```
@ -24,17 +25,17 @@ sudo apt install paprefs
虽然这款工具是图形化的,但作为普通用户在命令行中输入 `paprefs` 来启动它恐怕还是要更容易一些。
打开的窗口中有一些标签页,这些标签页内有一些可以调整的设置项。我们这里选择最后那个标签页,"Simultaneous Output。"
打开的窗口中有一些标签页,这些标签页内有一些可以调整的设置项。我们这里选择最后那个标签页,“Simultaneous Output。”
![Paprefs on Ubuntu][1]
这个标签页中没有什么内容,只是一个复选框用来启用设置。
这个标签页中没有什么内容,只是一个复选框用来启用设置。
下一步,打开常规的声音首选项。这在不同的发行版中位于不同的位置。在 Ubuntu 上,它位于 GNOME 系统设置内。
![Enable Simultaneous Audio][2]
打开声音首选项后,选择 "output" 标签页。勾选 "Simultaneous output" 单选按钮。现在它就成了你的默认输出了。
打开声音首选项后,选择 “output” 标签页。勾选 “Simultaneous output” 单选按钮。现在它就成了你的默认输出了。
### 测试一下
@ -42,7 +43,7 @@ sudo apt install paprefs
一切顺利的话,你就能从所有连接的设备中听到有声音传出了。
这就是所有要做的事了。此功能最适用于有多个设备(如 HDMI 端口和标准模拟输出)时。你当然也可以试一下其他配置。你还需要注意,只有一个音量控制器存在,因此你需要根据实际情况调整物理输出设备。
这就是所有要做的事了。此功能最适用于有多个设备(如 HDMI 端口和标准模拟输出)时。你当然也可以试一下其他配置。你还需要注意,只有一个音量控制器,因此你需要根据实际情况调整物理输出设备。
--------------------------------------------------------------------------------
@ -51,7 +52,7 @@ via: https://www.maketecheasier.com/play-sound-through-multiple-devices-linux/
作者:[Nick Congleton][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,194 @@
Yaourt 已死!在 Arch 上使用这些替代品
======
**前略Yaourt 曾是最流行的 AUR 助手,但现已停止开发。在这篇文章中,我们会为 Arch 衍生发行版们列出 Yaourt 最佳的替代品。**
[Arch User Repository][1] (常被称作 AUR是一个为 Arch 用户而生的社区驱动软件仓库。Debian/Ubuntu 用户的对应类比是 PPA。
AUR 包含了不直接被 [Arch Linux][2] 官方所背书的软件。如果有人想在 Arch 上发布软件或者包,它可以通过这个社区仓库提供。这让最终用户们可以使用到比默认仓库里更多的软件。
所以你该如何使用 AUR 呢?简单来说,你需要另外的工具以从 AUR 中安装软件。Arch 的包管理器 [pacman][3] 不直接支持 AUR。那些支持 AUR 的“特殊工具”我们称之为 [AUR 助手][4]。
Yaourt Yet AnOther User Repository Tool曾经`pacman` 的一个封装,便于用户在 Arch Linux 上安装 AUR 软件。它基本上采用和 `pacman` 一样的语法。Yaourt 对于 AUR 的搜索、安装,乃至冲突解决和包依赖关系维护都有着良好的支持。
然而Yaourt 的开发进度近来十分缓慢,甚至在 Arch Wiki 上已经被[列为][5]“停止或有问题”。[许多 Arch 用户认为它不安全][6] 进而开始寻找其它的 AUR 助手。
![Yaourt 以外的 AUR Helpers][7]
在这篇文章中,我们会介绍 Yaourt 最佳的替代品以便于你从 AUR 安装软件。
### 最好的 AUR 助手
我刻意忽略掉了例如 Trizen 和 Packer 这样的流行的选择,因为它们也被列为“停止或有问题”的了。
#### 1、 aurman
[aurman][8] 是最好的 AUR 助手之一,也能胜任 Yaourt 替代品的地位。它有非常类似于 `pacman` 的语法,可以支持所有的 `pacman` 操作。你可以搜索 AUR、解决包依赖在构建 AUR 包前检查 PKGBUILD 的内容等等。
aurman 的特性:
* aurman 支持所有 `pacman` 操作,并且引入了可靠的包依赖解决方案、冲突判定和<ruby>分包<rt>split package</rt></ruby>支持
* 线程化的 sudo 循环会在后台运行,所以你每次安装只需要输入一次管理员密码
* 提供开发包支持,并且可以区分显性安装和隐性安装的包
* 支持搜索 AUR 包和仓库
* 在构建 AUR 包之前,你可以检视并编辑 PKGBUILD 的内容
* 可以用作单独的 [包依赖解决工具][9]
安装 aurman
```
git clone https://aur.archlinux.org/aurman.git
cd aurman
makepkg -si
```
使用 aurman
用名字搜索:
```
aurman -Ss <package-name>
```
安装:
```
aurman -S &lt;package-name>
```
#### 2、 yay
[yay][10] 是下一个最好的 AUR 助手。它使用 Go 语言写成,宗旨是提供最少化用户输入的 `pacman` 界面、yaourt 式的搜索,而几乎没有任何依赖软件。
yay 的特性:
* `yay` 提供 AUR 表格补全,并且从 ABS 或 AUR 下载 PKGBUILD
* 支持收窄搜索,并且不需要引用 PKGBUILD 源
* `yay` 的二进制文件除了 `pacman` 以外别无依赖
* 提供先进的包依赖解决方案,以及在编译安装之后移除编译时的依赖
* 当在 `/etc/pacman.conf` 文件配置中启用了色彩时支持色彩输出
* `yay` 可被配置成只支持 AUR 或者 repo 里的软件包
安装 yay
你可以从 `git` 克隆并编译安装。
```
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
```
使用 yay
搜索:
```
yay -Ss <package-name>
```
安装:
```
yay -S <package-name>
```
#### 3、 pakku
[Pakku][11] 是另一个还处于开发早期的 pacman 封装,虽然它还处于开放早期,但这不说明它逊于其它任何 AUR 助手。Pakku 能很好地支持从 AUR 搜索和安装,并且也可以在安装后移除不必要的编译依赖。
pakku 的特性:
* 从 AUR 搜索和安装软件
* 检视不同构建之间的文件和变化
* 从官方仓库编译,并事后移除编译依赖
* 获取 PKGBUILD 以及 pacman 整合
* 类 pacman 的用户界面和选项支持
* 支持pacman 配置文件以及无需 PKGBUILD 源
安装 pakku
```
git clone https://aur.archlinux.org/pakku.git
cd pakku
makepkg -si
```
使用 pakku
搜索:
```
pakku -Ss spotify
```
安装:
```
pakku -S spotify
```
#### 4、 aurutils
[aurutils][12] 本质上是一堆使用 AUR 的自动化脚本的集合。它可以搜索 AUR、检查更新并且解决包依赖。
aurutils 的特性:
* aurutils 使用本地仓库以支持 pacman 文件,所有的包都支持 `asdeps`
* 不同的任务可以有多个仓库
* `aursync -u` 一键同步本地代码库
* `aursearch` 搜索提供 pkgbase、长格式和 raw 支持
* 能忽略指定包
安装 aurutils
```
git clone https://aur.archlinux.org/aurutils.git
cd aurutils
makepkg -si
```
使用 aurutils
搜索:
```
aurutils -Ss <package-name>
```
安装:
```
aurutils -S <package-name>
```
所有这些包,在有 Yaourt 或者其它 AUR 助手的情况下都可以直接安装。
### 写在最后
Arch Linux 有着[很多 AUR 助手][4] 可以自动完成 AUR 各方面的日常任务。很多用户依然使用 Yaourt 来完成 AUR 相关任务,每个人都有自己不一样的偏好,欢迎留言告诉我们你在 Arch 里使用什么,又有什么心得?
--------------------------------------------------------------------------------
via: https://itsfoss.com/best-aur-helpers/
作者:[Ambarish Kumar][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[Moelf](https://github.com/Moelf)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://itsfoss.com/author/ambarish/
[1]:https://wiki.archlinux.org/index.php/Arch_User_Repository
[2]:https://www.archlinux.org/
[3]:https://wiki.archlinux.org/index.php/pacman
[4]:https://wiki.archlinux.org/index.php/AUR_helpers
[5]:https://wiki.archlinux.org/index.php/AUR_helpers#Comparison_table
[6]:https://www.reddit.com/r/archlinux/comments/4azqyb/whats_so_bad_with_yaourt/
[7]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/06/no-yaourt-arch-800x450.jpeg
[8]:https://github.com/polygamma/aurman
[9]:https://github.com/polygamma/aurman/wiki/Using-aurman-as-dependency-solver
[10]:https://github.com/Jguer/yay
[11]:https://github.com/kitsunyan/pakku
[12]:https://github.com/AladW/aurutils

View File

@ -1,111 +0,0 @@
My Lisp Experiences and the Development of GNU Emacs
======
> (Transcript of Richard Stallman's Speech, 28 Oct 2002, at the International Lisp Conference).
Since none of my usual speeches have anything to do with Lisp, none of them were appropriate for today. So I'm going to have to wing it. Since I've done enough things in my career connected with Lisp I should be able to say something interesting.
My first experience with Lisp was when I read the Lisp 1.5 manual in high school. That's when I had my mind blown by the idea that there could be a computer language like that. The first time I had a chance to do anything with Lisp was when I was a freshman at Harvard and I wrote a Lisp interpreter for the PDP-11. It was a very small machine — it had something like 8k of memory — and I managed to write the interpreter in a thousand instructions. This gave me some room for a little bit of data. That was before I got to see what real software was like, that did real system jobs.
I began doing work on a real Lisp implementation with JonL White once I started working at MIT. I got hired at the Artificial Intelligence Lab not by JonL, but by Russ Noftsker, which was most ironic considering what was to come — he must have really regretted that day.
During the 1970s, before my life became politicized by horrible events, I was just going along making one extension after another for various programs, and most of them did not have anything to do with Lisp. But, along the way, I wrote a text editor, Emacs. The interesting idea about Emacs was that it had a programming language, and the user's editing commands would be written in that interpreted programming language, so that you could load new commands into your editor while you were editing. You could edit the programs you were using and then go on editing with them. So, we had a system that was useful for things other than programming, and yet you could program it while you were using it. I don't know if it was the first one of those, but it certainly was the first editor like that.
This spirit of building up gigantic, complicated programs to use in your own editing, and then exchanging them with other people, fueled the spirit of free-wheeling cooperation that we had at the AI Lab then. The idea was that you could give a copy of any program you had to someone who wanted a copy of it. We shared programs to whomever wanted to use them, they were human knowledge. So even though there was no organized political thought relating the way we shared software to the design of Emacs, I'm convinced that there was a connection between them, an unconscious connection perhaps. I think that it's the nature of the way we lived at the AI Lab that led to Emacs and made it what it was.
The original Emacs did not have Lisp in it. The lower level language, the non-interpreted language — was PDP-10 Assembler. The interpreter we wrote in that actually wasn't written for Emacs, it was written for TECO. It was our text editor, and was an extremely ugly programming language, as ugly as could possibly be. The reason was that it wasn't designed to be a programming language, it was designed to be an editor and command language. There were commands like 5l, meaning move five lines, or i and then a string and then an ESC to insert that string. You would type a string that was a series of commands, which was called a command string. You would end it with ESC ESC, and it would get executed.
Well, people wanted to extend this language with programming facilities, so they added some. For instance, one of the first was a looping construct, which was < >. You would put those around things and it would loop. There were other cryptic commands that could be used to conditionally exit the loop. To make Emacs, we (1) added facilities to have subroutines with names. Before that, it was sort of like Basic, and the subroutines could only have single letters as their names. That was hard to program big programs with, so we added code so they could have longer names. Actually, there were some rather sophisticated facilities; I think that Lisp got its unwind-protect facility from TECO.
We started putting in rather sophisticated facilities, all with the ugliest syntax you could ever think of, and it worked — people were able to write large programs in it anyway. The obvious lesson was that a language like TECO, which wasn't designed to be a programming language, was the wrong way to go. The language that you build your extensions on shouldn't be thought of as a programming language in afterthought; it should be designed as a programming language. In fact, we discovered that the best programming language for that purpose was Lisp.
It was Bernie Greenberg, who discovered that it was (2). He wrote a version of Emacs in Multics MacLisp, and he wrote his commands in MacLisp in a straightforward fashion. The editor itself was written entirely in Lisp. Multics Emacs proved to be a great success — programming new editing commands was so convenient that even the secretaries in his office started learning how to use it. They used a manual someone had written which showed how to extend Emacs, but didn't say it was a programming. So the secretaries, who believed they couldn't do programming, weren't scared off. They read the manual, discovered they could do useful things and they learned to program.
So Bernie saw that an application — a program that does something useful for you — which has Lisp inside it and which you could extend by rewriting the Lisp programs, is actually a very good way for people to learn programming. It gives them a chance to write small programs that are useful for them, which in most arenas you can't possibly do. They can get encouragement for their own practical use — at the stage where it's the hardest — where they don't believe they can program, until they get to the point where they are programmers.
At that point, people began to wonder how they could get something like this on a platform where they didn't have full service Lisp implementation. Multics MacLisp had a compiler as well as an interpreter — it was a full-fledged Lisp system — but people wanted to implement something like that on other systems where they had not already written a Lisp compiler. Well, if you didn't have the Lisp compiler you couldn't write the whole editor in Lisp — it would be too slow, especially redisplay, if it had to run interpreted Lisp. So we developed a hybrid technique. The idea was to write a Lisp interpreter and the lower level parts of the editor together, so that parts of the editor were built-in Lisp facilities. Those would be whatever parts we felt we had to optimize. This was a technique that we had already consciously practiced in the original Emacs, because there were certain fairly high level features which we re-implemented in machine language, making them into TECO primitives. For instance, there was a TECO primitive to fill a paragraph (actually, to do most of the work of filling a paragraph, because some of the less time-consuming parts of the job would be done at the higher level by a TECO program). You could do the whole job by writing a TECO program, but that was too slow, so we optimized it by putting part of it in machine language. We used the same idea here (in the hybrid technique), that most of the editor would be written in Lisp, but certain parts of it that had to run particularly fast would be written at a lower level.
Therefore, when I wrote my second implementation of Emacs, I followed the same kind of design. The low level language was not machine language anymore, it was C. C was a good, efficient language for portable programs to run in a Unix-like operating system. There was a Lisp interpreter, but I implemented facilities for special purpose editing jobs directly in C — manipulating editor buffers, inserting leading text, reading and writing files, redisplaying the buffer on the screen, managing editor windows.
Now, this was not the first Emacs that was written in C and ran on Unix. The first was written by James Gosling, and was referred to as GosMacs. A strange thing happened with him. In the beginning, he seemed to be influenced by the same spirit of sharing and cooperation of the original Emacs. I first released the original Emacs to people at MIT. Someone wanted to port it to run on Twenex — it originally only ran on the Incompatible Timesharing System we used at MIT. They ported it to Twenex, which meant that there were a few hundred installations around the world that could potentially use it. We started distributing it to them, with the rule that “you had to send back all of your improvements” so we could all benefit. No one ever tried to enforce that, but as far as I know people did cooperate.
Gosling did, at first, seem to participate in this spirit. He wrote in a manual that he called the program Emacs hoping that others in the community would improve it until it was worthy of that name. That's the right approach to take towards a community — to ask them to join in and make the program better. But after that he seemed to change the spirit, and sold it to a company.
At that time I was working on the GNU system (a free software Unix-like operating system that many people erroneously call “Linux”). There was no free software Emacs editor that ran on Unix. I did, however, have a friend who had participated in developing Gosling's Emacs. Gosling had given him, by email, permission to distribute his own version. He proposed to me that I use that version. Then I discovered that Gosling's Emacs did not have a real Lisp. It had a programming language that was known as mocklisp, which looks syntactically like Lisp, but didn't have the data structures of Lisp. So programs were not data, and vital elements of Lisp were missing. Its data structures were strings, numbers and a few other specialized things.
I concluded I couldn't use it and had to replace it all, the first step of which was to write an actual Lisp interpreter. I gradually adapted every part of the editor based on real Lisp data structures, rather than ad hoc data structures, making the data structures of the internals of the editor exposable and manipulable by the user's Lisp programs.
The one exception was redisplay. For a long time, redisplay was sort of an alternate world. The editor would enter the world of redisplay and things would go on with very special data structures that were not safe for garbage collection, not safe for interruption, and you couldn't run any Lisp programs during that. We've changed that since — it's now possible to run Lisp code during redisplay. It's quite a convenient thing.
This second Emacs program was free software in the modern sense of the term — it was part of an explicit political campaign to make software free. The essence of this campaign was that everybody should be free to do the things we did in the old days at MIT, working together on software and working with whomever wanted to work with us. That is the basis for the free software movement — the experience I had, the life that I've lived at the MIT AI lab — to be working on human knowledge, and not be standing in the way of anybody's further using and further disseminating human knowledge.
At the time, you could make a computer that was about the same price range as other computers that weren't meant for Lisp, except that it would run Lisp much faster than they would, and with full type checking in every operation as well. Ordinary computers typically forced you to choose between execution speed and good typechecking. So yes, you could have a Lisp compiler and run your programs fast, but when they tried to take `car` of a number, it got nonsensical results and eventually crashed at some point.
The Lisp machine was able to execute instructions about as fast as those other machines, but each instruction — a car instruction would do data typechecking — so when you tried to get the car of a number in a compiled program, it would give you an immediate error. We built the machine and had a Lisp operating system for it. It was written almost entirely in Lisp, the only exceptions being parts written in the microcode. People became interested in manufacturing them, which meant they should start a company.
There were two different ideas about what this company should be like. Greenblatt wanted to start what he called a “hacker” company. This meant it would be a company run by hackers and would operate in a way conducive to hackers. Another goal was to maintain the AI Lab culture (3). Unfortunately, Greenblatt didn't have any business experience, so other people in the Lisp machine group said they doubted whether he could succeed. They thought that his plan to avoid outside investment wouldn't work.
Why did he want to avoid outside investment? Because when a company has outside investors, they take control and they don't let you have any scruples. And eventually, if you have any scruples, they also replace you as the manager.
So Greenblatt had the idea that he would find a customer who would pay in advance to buy the parts. They would build machines and deliver them; with profits from those parts, they would then be able to buy parts for a few more machines, sell those and then buy parts for a larger number of machines, and so on. The other people in the group thought that this couldn't possibly work.
Greenblatt then recruited Russell Noftsker, the man who had hired me, who had subsequently left the AI Lab and created a successful company. Russell was believed to have an aptitude for business. He demonstrated this aptitude for business by saying to the other people in the group, “Let's ditch Greenblatt, forget his ideas, and we'll make another company.” Stabbing in the back, clearly a real businessman. Those people decided they would form a company called Symbolics. They would get outside investment, not have scruples, and do everything possible to win.
But Greenblatt didn't give up. He and the few people loyal to him decided to start Lisp Machines Inc. anyway and go ahead with their plans. And what do you know, they succeeded! They got the first customer and were paid in advance. They built machines and sold them, and built more machines and more machines. They actually succeeded even though they didn't have the help of most of the people in the group. Symbolics also got off to a successful start, so you had two competing Lisp machine companies. When Symbolics saw that LMI was not going to fall flat on its face, they started looking for ways to destroy it.
Thus, the abandonment of our lab was followed by “war” in our lab. The abandonment happened when Symbolics hired away all the hackers, except me and the few who worked at LMI part-time. Then they invoked a rule and eliminated people who worked part-time for MIT, so they had to leave entirely, which left only me. The AI lab was now helpless. And MIT had made a very foolish arrangement with these two companies. It was a three-way contract where both companies licensed the use of Lisp machine system sources. These companies were required to let MIT use their changes. But it didn't say in the contract that MIT was entitled to put them into the MIT Lisp machine systems that both companies had licensed. Nobody had envisioned that the AI lab's hacker group would be wiped out, but it was.
So Symbolics came up with a plan (4). They said to the lab, “We will continue making our changes to the system available for you to use, but you can't put it into the MIT Lisp machine system. Instead, we'll give you access to Symbolics' Lisp machine system, and you can run it, but that's all you can do.”
This, in effect, meant that they demanded that we had to choose a side, and use either the MIT version of the system or the Symbolics version. Whichever choice we made determined which system our improvements went to. If we worked on and improved the Symbolics version, we would be supporting Symbolics alone. If we used and improved the MIT version of the system, we would be doing work available to both companies, but Symbolics saw that we would be supporting LMI because we would be helping them continue to exist. So we were not allowed to be neutral anymore.
Up until that point, I hadn't taken the side of either company, although it made me miserable to see what had happened to our community and the software. But now, Symbolics had forced the issue. So, in an effort to help keep Lisp Machines Inc. going (5) — I began duplicating all of the improvements Symbolics had made to the Lisp machine system. I wrote the equivalent improvements again myself (i.e., the code was my own).
After a while (6), I came to the conclusion that it would be best if I didn't even look at their code. When they made a beta announcement that gave the release notes, I would see what the features were and then implement them. By the time they had a real release, I did too.
In this way, for two years, I prevented them from wiping out Lisp Machines Incorporated, and the two companies went on. But, I didn't want to spend years and years punishing someone, just thwarting an evil deed. I figured they had been punished pretty thoroughly because they were stuck with competition that was not leaving or going to disappear (7). Meanwhile, it was time to start building a new community to replace the one that their actions and others had wiped out.
The Lisp community in the 70s was not limited to the MIT AI Lab, and the hackers were not all at MIT. The war that Symbolics started was what wiped out MIT, but there were other events going on then. There were people giving up on cooperation, and together this wiped out the community and there wasn't much left.
Once I stopped punishing Symbolics, I had to figure out what to do next. I had to make a free operating system, that was clear — the only way that people could work together and share was with a free operating system.
At first, I thought of making a Lisp-based system, but I realized that wouldn't be a good idea technically. To have something like the Lisp machine system, you needed special purpose microcode. That's what made it possible to run programs as fast as other computers would run their programs and still get the benefit of typechecking. Without that, you would be reduced to something like the Lisp compilers for other machines. The programs would be faster, but unstable. Now that's okay if you're running one program on a timesharing system — if one program crashes, that's not a disaster, that's something your program occasionally does. But that didn't make it good for writing the operating system in, so I rejected the idea of making a system like the Lisp machine.
I decided instead to make a Unix-like operating system that would have Lisp implementations to run as user programs. The kernel wouldn't be written in Lisp, but we'd have Lisp. So the development of that operating system, the GNU operating system, is what led me to write the GNU Emacs. In doing this, I aimed to make the absolute minimal possible Lisp implementation. The size of the programs was a tremendous concern.
There were people in those days, in 1985, who had one-megabyte machines without virtual memory. They wanted to be able to use GNU Emacs. This meant I had to keep the program as small as possible.
For instance, at the time the only looping construct was while, which was extremely simple. There was no way to break out of the while statement, you just had to do a catch and a throw, or test a variable that ran the loop. That shows how far I was pushing to keep things small. We didn't have caar and cadr and so on; “squeeze out everything possible” was the spirit of GNU Emacs, the spirit of Emacs Lisp, from the beginning.
Obviously, machines are bigger now, and we don't do it that way any more. We put in caar and cadr and so on, and we might put in another looping construct one of these days. We're willing to extend it some now, but we don't want to extend it to the level of common Lisp. I implemented Common Lisp once on the Lisp machine, and I'm not all that happy with it. One thing I don't like terribly much is keyword arguments (8). They don't seem quite Lispy to me; I'll do it sometimes but I minimize the times when I do that.
That was not the end of the GNU projects involved with Lisp. Later on around 1995, we were looking into starting a graphical desktop project. It was clear that for the programs on the desktop, we wanted a programming language to write a lot of it in to make it easily extensible, like the editor. The question was what it should be.
At the time, TCL was being pushed heavily for this purpose. I had a very low opinion of TCL, basically because it wasn't Lisp. It looks a tiny bit like Lisp, but semantically it isn't, and it's not as clean. Then someone showed me an ad where Sun was trying to hire somebody to work on TCL to make it the “de-facto standard extension language” of the world. And I thought, “We've got to stop that from happening.” So we started to make Scheme the standard extensibility language for GNU. Not Common Lisp, because it was too large. The idea was that we would have a Scheme interpreter designed to be linked into applications in the same way TCL was linked into applications. We would then recommend that as the preferred extensibility package for all GNU programs.
There's an interesting benefit you can get from using such a powerful language as a version of Lisp as your primary extensibility language. You can implement other languages by translating them into your primary language. If your primary language is TCL, you can't very easily implement Lisp by translating it into TCL. But if your primary language is Lisp, it's not that hard to implement other things by translating them. Our idea was that if each extensible application supported Scheme, you could write an implementation of TCL or Python or Perl in Scheme that translates that program into Scheme. Then you could load that into any application and customize it in your favorite language and it would work with other customizations as well.
As long as the extensibility languages are weak, the users have to use only the language you provided them. Which means that people who love any given language have to compete for the choice of the developers of applications — saying “Please, application developer, put my language into your application, not his language.” Then the users get no choices at all — whichever application they're using comes with one language and they're stuck with [that language]. But when you have a powerful language that can implement others by translating into it, then you give the user a choice of language and we don't have to have a language war anymore. That's what we're hoping Guile, our scheme interpreter, will do. We had a person working last summer finishing up a translator from Python to Scheme. I don't know if it's entirely finished yet, but for anyone interested in this project, please get in touch. So that's the plan we have for the future.
I haven't been speaking about free software, but let me briefly tell you a little bit about what that means. Free software does not refer to price; it doesn't mean that you get it for free. (You may have paid for a copy, or gotten a copy gratis.) It means that you have freedom as a user. The crucial thing is that you are free to run the program, free to study what it does, free to change it to suit your needs, free to redistribute the copies of others and free to publish improved, extended versions. This is what free software means. If you are using a non-free program, you have lost crucial freedom, so don't ever do that.
The purpose of the GNU project is to make it easier for people to reject freedom-trampling, user-dominating, non-free software by providing free software to replace it. For those who don't have the moral courage to reject the non-free software, when that means some practical inconvenience, what we try to do is give a free alternative so that you can move to freedom with less of a mess and less of a sacrifice in practical terms. The less sacrifice the better. We want to make it easier for you to live in freedom, to cooperate.
This is a matter of the freedom to cooperate. We're used to thinking of freedom and cooperation with society as if they are opposites. But here they're on the same side. With free software you are free to cooperate with other people as well as free to help yourself. With non-free software, somebody is dominating you and keeping people divided. You're not allowed to share with them, you're not free to cooperate or help society, anymore than you're free to help yourself. Divided and helpless is the state of users using non-free software.
We've produced a tremendous range of free software. We've done what people said we could never do; we have two operating systems of free software. We have many applications and we obviously have a lot farther to go. So we need your help. I would like to ask you to volunteer for the GNU project; help us develop free software for more jobs. Take a look at [http://www.gnu.org/help][1] to find suggestions for how to help. If you want to order things, there's a link to that from the home page. If you want to read about philosophical issues, look in /philosophy. If you're looking for free software to use, look in /directory, which lists about 1900 packages now (which is a fraction of all the free software out there). Please write more and contribute to us. My book of essays, “Free Software and Free Society”, is on sale and can be purchased at [www.gnu.org][2]. Happy hacking!
--------------------------------------------------------------------------------
via: https://www.gnu.org/gnu/rms-lisp.html
作者:[Richard Stallman][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.gnu.org
[1]:https://www.gnu.org/help/
[2]:http://www.gnu.org/

View File

@ -1,186 +0,0 @@
FSSlc translating
View The Contents Of An Archive Or Compressed File Without Extracting It
======
![](https://www.ostechnix.com/wp-content/uploads/2018/07/View-The-Contents-Of-An-Archive-Or-Compressed-File-720x340.png)
In this tutorial, we are going to learn how to view the contents of an Archive and/or Compressed file without actually extracting it in Unix-like operating systems. Before going further, let be clear about Archive and compress files. There is significant difference between both. The Archiving is the process of combining multiple files or folders or both into a single file. In this case, the resulting file is not compressed. The compressing is a method of combining multiple files or folders or both into a single file and finally compress the resulting file. The archive is not a compressed file, but the compressed file can be an archive. Clear? Well, let us get to the topic.
### View The Contents Of An Archive Or Compressed File Without Extracting It
Thanks to Linux community, there are many command line applications are available to do it. Let us going to see some of them with examples.
**1\. Using Vim Editor**
Vim is not just an editor. Using Vim, we can do numerous things. The following command displays the contents of an compressed archive file without decompressing it.
```
$ vim ostechnix.tar.gz
```
![][2]
You can even browse through the archive and open the text files (if there are any) in the archive as well. To open a text file, just put the mouse cursor in-front of the file using arrow keys and hit ENTER to open it.
**2\. Using Tar command**
To list the contents of a tar archive file, run:
```
$ tar -tf ostechnix.tar
ostechnix/
ostechnix/image.jpg
ostechnix/file.pdf
ostechnix/song.mp3
```
Or, use **-v** flag to view the detailed properties of the archive file, such as permissions, file owner, group, creation date etc.
```
$ tar -tvf ostechnix.tar
drwxr-xr-x sk/users 0 2018-07-02 19:30 ostechnix/
-rw-r--r-- sk/users 53632 2018-06-29 15:57 ostechnix/image.jpg
-rw-r--r-- sk/users 156831 2018-06-04 12:37 ostechnix/file.pdf
-rw-r--r-- sk/users 9702219 2018-04-25 20:35 ostechnix/song.mp3
```
**3\. Using Rar command**
To view the contents of a rar file, simply do:
```
$ rar v ostechnix.rar
RAR 5.60 Copyright (c) 1993-2018 Alexander Roshal 24 Jun 2018
Trial version Type 'rar -?' for help
Archive: ostechnix.rar
Details: RAR 5
Attributes Size Packed Ratio Date Time Checksum Name
----------- --------- -------- ----- ---------- ----- -------- ----
-rw-r--r-- 53632 52166 97% 2018-06-29 15:57 70260AC4 ostechnix/image.jpg
-rw-r--r-- 156831 139094 88% 2018-06-04 12:37 C66C545E ostechnix/file.pdf
-rw-r--r-- 9702219 9658527 99% 2018-04-25 20:35 DD875AC4 ostechnix/song.mp3
----------- --------- -------- ----- ---------- ----- -------- ----
9912682 9849787 99% 3
```
**4\. Using Unrar command**
You can also do the same using **Unrar** command with **l** flag as shown below.
```
$ unrar l ostechnix.rar
UNRAR 5.60 freeware Copyright (c) 1993-2018 Alexander Roshal
Archive: ostechnix.rar
Details: RAR 5
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 53632 2018-06-29 15:57 ostechnix/image.jpg
-rw-r--r-- 156831 2018-06-04 12:37 ostechnix/file.pdf
-rw-r--r-- 9702219 2018-04-25 20:35 ostechnix/song.mp3
----------- --------- ---------- ----- ----
9912682 3
```
**5\. Using Zip command**
To view the contents of a zip file without extracting it, use the following zip command:
```
$ zip -sf ostechnix.zip
Archive contains:
Life advices.jpg
Total 1 entries (597219 bytes)
```
**6. Using Unzip command
**
You can also use Unzip command with -l flag to display the contents of a zip file like below.
```
$ unzip -l ostechnix.zip
Archive: ostechnix.zip
Length Date Time Name
--------- ---------- ----- ----
597219 2018-04-09 12:48 Life advices.jpg
--------- -------
597219 1 file
```
**7\. Using Zipinfo command**
```
$ zipinfo ostechnix.zip
Archive: ostechnix.zip
Zip file size: 584859 bytes, number of entries: 1
-rw-r--r-- 6.3 unx 597219 bx defN 18-Apr-09 12:48 Life advices.jpg
1 file, 597219 bytes uncompressed, 584693 bytes compressed: 2.1%
```
As you can see, the above command displays the contents of the zip file, its permissions, creating date, and percentage of compression etc.
**8. Using Zcat command
**
To view the contents of a compressed archive file without extracting it using **zcat** command, we do:
```
$ zcat ostechnix.tar.gz
```
The zcat is same as “gunzip -c” command. So, you can also use the following command to view the contents of the archive/compressed file:
```
$ gunzip -c ostechnix.tar.gz
```
**9. Using Zless command
**
To view the contents of an archive/compressed file using Zless command, simply do:
```
$ zless ostechnix.tar.gz
```
This command is similar to “less” command where it displays the output page by page.
**10. Using Less command
**
As you might already know, the **less** command can be used to open a file for interactive reading, allowing scrolling and search.
Run the following command to view the contents of an archive/compressed file using less command:
```
$ less ostechnix.tar.gz
```
And, thats all for now. You know now how to view the contents of an archive of compressed file using various commands in Linux. Hope you find this useful. More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-view-the-contents-of-an-archive-or-compressed-file-without-extracting-it/
作者:[SK][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.ostechnix.com/author/sk/
[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[2]:http://www.ostechnix.com/wp-content/uploads/2018/07/vim.png

View File

@ -1,3 +1,5 @@
translating by ypingcn
Tips for using the top command in Linux
======

View File

@ -0,0 +1,109 @@
我的Lisp体验和GNU Emacs的开发
Richard Stallman的演讲稿2002年10月28日国际Lisp会议
由于我的常见演讲都没有与Lisp有任何关系因此它们都不适用于今天。所以我将不得不放弃它。由于我在与Lisp相关的职业生涯中做了足够的事情我应该能够说些有趣的事情。
我第一次使用Lisp是在高中时阅读Lisp 1.5手册。就在那时我的想法是因为可能有类似的计算机语言。我第一次有机会和Lisp做任何事情的时候是我在哈佛大学的新生我为PDP-11写了一个Lisp解释器。这是一个非常小的机器 - 它有类似8k的内存 - 我设法用一千个指令编写解释器。这为我提供了一些数据空间。那是在我看到真正的软件之前,它做了真正的系统工作。
一旦我开始在麻省理工学院工作我开始与JonL White一起开展真正的Lisp实现工作。我在人工智能实验室雇用的不是JonL而是来自Russ Noftsker考虑到将要发生的事情这是最具讽刺意味的 - 他当然一定非常后悔。
在20世纪70年代在我的生活因可怕的事件而变得政治化之前我只是为了各种程序而一个接一个地进行扩展其中大多数与Lisp没有任何关系。但是在此过程中我写了一个文本编辑器Emacs。关于Emacs的有趣想法是它有一种编程语言用户的编辑命令将用这种解释的编程语言编写这样你就可以在编辑时将新命令加载到编辑器中。您可以编辑正在使用的程序然后继续编辑它们。所以我们有一个对编程以外的东西有用的系统但你可以在使用它的时候对它进行编程。我不知道它是否是第一个但它肯定是第一个这样的编辑。
这种构建巨大而复杂的程序以便在您自己编辑中使用然后与其他人交换这种精神的精神激发了我们在AI实验室进行的自由合作的精神。我们的想法是您可以将任何程序的副本提供给想要其副本的人。我们与想要使用它们的人共享程序它们是人类的知识。因此尽管没有有组织的政治思想与我们将软件与Emacs的设计共享的方式联系起来但我确信它们之间存在联系也许是一种无意识的联系。我认为这是我们在AI实验室生活的方式的本质它导致了Emacs并使它成为现实。
最初的Emacs里面没有Lisp。较低级别的语言非解释性语言 - 是PDP-10汇编程序。我们写的解释实际上并不是为Emacs编写的它是为TECO编写的。这是我们的文本编辑器并且是一种非常难看的编程语言尽可能难看。原因是它不是一种编程语言它被设计成一种编辑器和命令语言。有一些命令如'5l',意思是'移动五行',或'i'然后是一个字符串然后是一个ESC来插入该字符串。您将键入一个字符串该字符串是一系列命令称为命令字符串。你会用ESC ESC结束它它会被执行。
好吧,人们想用编程工具扩展这种语言,所以他们添加了一些。例如,第一个是循环结构,它是<>。你会把它们放在周围它会循环。还有其他神秘的命令可用于有条件地退出循环。为了制作Emacs我们1添加了具有名称的子程序的工具。在此之前它有点像Basic子程序只能用单个字母作为名称。这很难用大型程序编程因此我们添加了代码以便它们可以有更长的名称。实际上有一些相当复杂的设施; 我认为Lisp得到了TECO的放松保护设施。
我们开始使用相当复杂的设施,所有这些都是你能想到的最丑陋的语法,并且它起作用了 - 人们无论如何都能够在其中编写大型程序。显而易见的教训是像TECO这样的语言并没有被设计成编程语言这是错误的方法。您构建扩展的语言不应该被认为是事后的编程语言; 它应该被设计为编程语言。实际上我们发现用于此目的的最佳编程语言是Lisp。
是伯尼格林伯格他发现它是2。他在Multics MacLisp中编写了一个版本的Emacs并且他以直截了当的方式在MacLisp中编写了他的命令。编辑器本身完全是用Lisp编写的。事实证明Multics Emacs取得了巨大成功 - 编写新的编辑命令非常方便甚至他办公室的秘书也开始学习如何使用它。他们使用了某人编写的手册其中展示了如何扩展Emacs但并没有说这是一个编程。所以那些认为自己无法编程的秘书并没有被吓跑。他们阅读了手册发现他们可以做有用的事情并且他们学会了编程。
因此,伯尼看到了一个应用程序 - 一个对你有用的程序 - 里面有Lisp你可以通过重写Lisp程序来扩展它实际上是人们学习编程的一种非常好的方式。它让他们有机会编写对他们有用的小程序这在大多数领域是你不可能做到的。他们可以鼓励他们自己的实际用途 - 在最困难的阶段 - 他们不相信他们可以编程,直到他们达到程序员的程度。
那时人们开始想知道如何在他们没有完整服务Lisp实现的平台上得到这样的东西。Multics MacLisp有一个编译器和一个解释器 - 它是一个成熟的Lisp系统 - 但是人们希望在其他尚未编写Lisp编译器的系统上实现类似的东西。好吧如果你没有Lisp编译器你就无法在Lisp中编写整个编辑器 - 如果它必须运行解释的Lisp那就太慢了尤其是重新编译。所以我们开发了一种混合技术。我的想法是编写一个Lisp解释器和编辑器的低级部分以便编辑器的部分内置Lisp工具。这些将是我们认为必须优化的任何部分。这是我们已经在原始Emacs中有意识地实践的一种技术因为我们在机器语言中重新实现了某些相当高级别的特性使它们成为TECO原语。例如有一个TECO原语来填充段落实际上要完成填充段落的大部分工作因为一些耗时较少的部分工作将由TECO程序在更高级别完成 。您可以通过编写TECO程序来完成整个工作但这太慢了所以我们通过将其中的一部分放在机器语言中来优化它。我们在这里使用了相同的想法在混合技术中大多数编辑器都是用Lisp编写的但是必须以特别快的速度运行的某些部分才能在较低级别编写。因为我们在机器语言中重新实现了某些相当高级别的功能使它们成为TECO原语。例如有一个TECO原语来填充段落实际上要完成填充段落的大部分工作因为一些耗时较少的部分工作将由TECO程序在更高级别完成 。您可以通过编写TECO程序来完成整个工作但这太慢了所以我们通过将其中的一部分放在机器语言中来优化它。我们在这里使用了相同的想法在混合技术中大多数编辑器都是用Lisp编写的但是必须以特别快的速度运行的某些部分才能在较低级别编写。因为我们在机器语言中重新实现了某些相当高级别的功能使它们成为TECO原语。例如有一个TECO原语来填充段落实际上要完成填充段落的大部分工作因为一些耗时较少的部分工作将由TECO程序在更高级别完成 。您可以通过编写TECO程序来完成整个工作但这太慢了所以我们通过将其中的一部分放在机器语言中来优化它。我们在这里使用了相同的想法在混合技术中大多数编辑器都是用Lisp编写的但是必须以特别快的速度运行的某些部分才能在较低级别编写。完成填写段落的大部分工作因为一些耗时较少的工作部分将由TECO计划在更高层次完成。您可以通过编写TECO程序来完成整个工作但这太慢了所以我们通过将其中的一部分放在机器语言中来优化它。我们在这里使用了相同的想法在混合技术中大多数编辑器都是用Lisp编写的但是必须以特别快的速度运行的某些部分才能在较低级别编写。完成填写段落的大部分工作因为一些耗时较少的工作部分将由TECO计划在更高层次完成。您可以通过编写TECO程序来完成整个工作但这太慢了所以我们通过将其中的一部分放在机器语言中来优化它。我们在这里使用了相同的想法在混合技术中大多数编辑器都是用Lisp编写的但是必须以特别快的速度运行的某些部分才能在较低级别编写。
因此当我编写第二个Emacs实现时我遵循了同样的设计。低级语言不再是机器语言它是C. C是便携式程序在类Unix操作系统中运行的一种好的高效的语言。有一个Lisp解释器但我直接在C中实现了专用编辑工作的工具 - 操作编辑缓冲区,插入前导文本,读取和写入文件,重新显示屏幕上的缓冲区,管理编辑器窗口。
现在这不是第一个用C编写并在Unix上运行的Emacs。第一部由James Gosling撰写被称为GosMacs。他身上发生了一件奇怪的事。起初他似乎受到原始Emacs的共享和合作精神的影响。我首先向麻省理工学院的人们发布了最初的Emacs。有人希望将它移植到Twenex上运行 - 它最初只运行在我们在麻省理工学院使用的不兼容的分时系统。他们将它移植到Twenex这意味着全世界有几百个可能会使用它的安装。我们开始将它分发给他们其规则是“您必须将所有改进发回”这样我们才能受益。没有人试图强制执行但据我所知人们确实合作。
起初戈斯林似乎参与了这种精神。他在手册中写道他称Emacs计划希望社区中的其他人能够改进它直到它值得这个名字。这是采用社区的正确方法 - 要求他们加入并使计划更好。但在那之后,他似乎改变了精​​神,并把它卖给了一家公司。
那时我正在研究GNU系统一种类似Unix的自由软件操作系统许多人错误称之为“Linux”。没有在Unix上运行的免费软件Emacs编辑器。然而我确实有一位朋友曾参与开发Gosling的Emacs。戈斯林通过电子邮件允许他分发自己的版本。他向我建议我使用那个版本。然后我发现Gosling的Emacs没有真正的Lisp。它有一种被称为'mocklisp'的编程语言它在语法上看起来像Lisp但没有Lisp的数据结构。所以程序不是数据而且缺少Lisp的重要元素。它的数据结构是字符串数字和一些其他专门的东西。
我总结说我无法使用它并且必须全部替换它第一步是编写一个实际的Lisp解释器。我逐渐调整了编辑器的每个部分基于真正的Lisp数据结构而不是ad hoc数据结构使得编辑器内部的数据结构可以由用户的Lisp程序公开和操作。
唯一的例外是重新显示。很长一段时间重新显示是一个替代世界。编辑器将进入重新显示的世界并且会继续使用非常特殊的数据结构这些数据结构对于垃圾收集是不安全的不会安全中断并且在此期间您无法运行任何Lisp程序。我们已经改变了 - 因为现在可以在重新显示期间运行Lisp代码。这是一件非常方便的事情。
第二个Emacs计划是现代意义上的“自由软件” - 它是使软件免费的明确政治运动的一部分。这次活动的实质是每个人都应该自由地做我们过去在麻省理工学院做的事情,共同开发软件并与想与我们合作的任何人一起工作。这是自由软件运动的基础 - 我拥有的经验,我在麻省理工学院人工智能实验室的生活 - 致力于人类知识,而不是阻碍任何人进一步使用和进一步传播人类知识。
当时您可以制作一台与其他不适合Lisp的计算机价格相同的计算机除了它可以比它们更快地运行Lisp并且在每个操作中都进行全类型检查。普通计算机通常迫使您在执行速度和良好的类型检查之间做出选择。所以是的你可以拥有一个Lisp编译器并快速运行你的程序但是当他们试图获取car一个数字时它会得到无意义的结果并最终在某些时候崩溃。
Lisp机器能够以与其他机器一样快的速度执行指令但是每条指令 - 汽车指令都会进行数据类型检查 - 所以当你试图在编译的程序中得到一个数字的汽车时它会立即给你一个错误。我们构建了机器并为它配备了Lisp操作系统。它几乎完全是用Lisp编写的唯一的例外是在微码中编写的部分。人们开始对制造它们感兴趣这意味着他们应该创办公司。
关于这家公司应该是什么样的有两种不同的想法。格林布莱特希望开始他所谓的“黑客”公司。这意味着它将成为一家由黑客运营的公司并以有利于黑客的方式运营。另一个目标是维持AI Lab文化3。不幸的是Greenblatt没有任何商业经验所以Lisp机器组的其他人说他们怀疑自己能否成功。他们认为他避免外来投资的计划是行不通的。
他为什么要避免外来投资?因为当一家公司有外部投资者时,他们会接受控制,他们不会让你有任何顾忌。最后,如果你有任何顾忌,他们也会取代你作为经理。
所以Greenblatt认为他会找到一个会提前支付购买零件的顾客。他们会建造机器并交付它们; 通过这些零件的利润,他们将能够为更多的机器购买零件,销售这些零件,然后为更多的机器购买零件,等等。小组中的其他人认为这不可行。
然后Greenblatt招募了聘请我的Russell Noftsker后来他离开了AI Lab并创建了一家成功的公司。据信拉塞尔有商业天赋。他通过对群体中的其他人说“让我们放弃格林布拉特忘记他的想法我们将成为另一家公司。”他展示了这种商业天赋。在后面刺伤显然是一个真正的商人。那些人决定他们组建一家名为Symbolics的公司。他们会得到外部投资没有顾忌并尽一切可能获胜。
但格林布拉特没有放弃。无论如何他和忠于他的少数人决定启动Lisp Machines Inc.并继续他们的计划。你知道什么他们成功了他们得到了第一个客户并提前付款。他们建造机器并出售它们并建造了更多的机器和更多的机器。尽管他们没有得到团队中大多数人的帮助但他们确实取得了成功。Symbolics也取得了成功的开始所以你有两个竞争的Lisp机器公司。当Symbolics看到LMI不会掉在脸上时他们开始寻找破坏它的方法。
因此放弃我们的实验室之后在我们的实验室中进行了“战争”。除了我和少数在LMI兼职工作的人之外当Symbolics雇佣了所有的黑客时遗弃了。然后他们引用了一条规则并且淘汰了为麻省理工学院做兼职工作的人所以他们不得不完全离开只剩下我。人工智能实验室现在无能为力。麻省理工学院与这两家公司做了非常愚蠢的安排。这是一份三方合同两家公司都许可使用Lisp机器系统源。这些公司被要求让麻省理工学院使用他们的变化。但它没有在合同中说MIT有权将它们放入两家公司获得许可的MIT Lisp机器系统中。没有人设想AI实验室的黑客组织会被彻底消灭但确实如此。
因此Symbolics提出了一个计划4。他们对实验室说“我们将继续对可供您使用的系统进行更改但您无法将其置于MIT Lisp机器系统中。相反我们将允许您访问Symbolics的Lisp机器系统您可以运行它但这就是您所能做的一切。“
实际上这意味着他们要求我们必须选择一个侧面并使用MIT版本的系统或Symbolics版本。无论我们做出哪种选择都决定了我们改进的系统。如果我们研究并改进了Symbolics版本我们就会单独支持Symbolics。如果我们使用并改进了MIT版本的系统我们将为两家公司提供工作但是Symbolics认为我们将支持LMI因为我们将帮助它们继续存在。所以我们不再被允许保持中立。
直到那时我还没有站在任何一家公司的一边尽管让我很难看到我们的社区和软件发生了什么。但现在Symbolics迫使这个问题。因此为了帮助保持Lisp Machines Inc.5 - 我开始复制Symbolics对Lisp机器系统所做的所有改进。我自己再次写了相同的改进即代码是我自己的
过了一会儿6我得出结论如果我甚至不看他们的代码那将是最好的。当他们发布了发布说明的beta版时我会看到这些功能是什么然后实现它们。当他们真正发布时我也做了。
通过这种方式两年来我阻止他们消灭Lisp Machines Incorporated两家公司继续进行。但是我不想花费数年和数年来惩罚某人只是挫败了一个邪恶的行为。我认为他们受到了相当彻底的惩罚因为他们被那些没有离开或将要消失的竞争所困扰7。与此同时现在是时候开始建立一个新社区来取代他们的行动和其他人已经消灭的社区。
70年代的Lisp社区不仅限于麻省理工学院人工智能实验室而且黑客并非都在麻省理工学院。Symbolics开始的战争是麻省理工学院的战争但当时还有其他事件正在发生。有人放弃了合作共同消灭了社区没有多少人离开。
一旦我停止惩罚Symbolics我必须弄清楚下一步该做什么。我必须制作一个免费的操作系统这很清楚 - 人们可以一起工作和共享的唯一方法是使用免费的操作系统。
起初我想过制作一个基于Lisp的系统但我意识到这在技术上不是一个好主意。要拥有像Lisp机器系统这样的东西你需要特殊用途的微码。这使得以其他计算机运行程序的速度运行程序成为可能并且仍然可以获得类型检查的好处。没有它你将被简化为类似其他机器的Lisp编译器。程序会更快但不稳定。如果你在分时系统上运行一个程序就好了 - 如果一个程序崩溃那不是灾难这是你的程序偶尔会做的事情。但这并不能很好地编写操作系统所以我拒绝了制作像Lisp机器这样的系统的想法。
我决定改造一个类似Unix的操作系统让Lisp实现作为用户程序运行。内核不会用Lisp编写但我们有Lisp。因此操作系统GNU操作系统的开发使我编写了GNU Emacs。在这样做的过程中我的目标是实现绝对最小化的Lisp实现。节目的规模是一个巨大的问题。
那些日子里1985年有人拥有一台没有虚拟内存的1兆字节机器。他们希望能够使用GNU Emacs。这意味着我必须保持程序尽可能小。
例如,当时唯一的循环结构是'while',这非常简单。没有办法打破'while'语句你只需要执行catch和throw或者测试运行循环的变量。这表明我在努力保持小事做多远。我们没有'caar'和'cadr'等等; “挤出一切可能”是从一开始就是Emacs Lisp精神的GNU Emacs的精神。
显然,机器现在变大了,我们不再这样做了。我们放入'caar'和'cadr'等等我们可能会在其中一天进行另一个循环构造。我们现在愿意扩展它但我们不想将它扩展到常见的Lisp级别。我在Lisp机器上实现了一次Common Lisp我对此并不满意。我不太喜欢的一件事是关键字参数8。他们对我来说似乎不太好看; 我有时候会这样做,但是当我这样做时,我会尽量减少。
这不是与Lisp有关的GNU项目的结束。后来在1995年左右我们开始考虑启动一个图形桌面项目。很明显对于桌面上的程序我们希望编程语言能够编写大量内容以使其易于扩展就像编辑器一样。问题是应该是什么。
当时为了这个目的TCL正在被大力推动。我对TCL的看法很低主要是因为它不是Lisp。它看起来有点像Lisp但在语义上它不是而且它不那么干净。然后有人向我展示了一则广告其中Sun试图聘请某人在TCL工作使其成为世界“事实上的标准扩展语言”。我想“我们必须阻止这种情况发生。”因此我们开始将Scheme作为GNU的标准可扩展性语言。不是Common Lisp因为它太大了。我们的想法是我们将有一个Scheme解释器设计为以与TCL链接到应用程序相同的方式链接到应用程序中。然后我们建议将其作为所有GNU程序的首选可扩展性包。
使用像Lisp这样强大的语言作为主要的可扩展性语言可以获得一个有趣的好处。您可以通过将其翻译成主要语言来实现其他语言。如果您的主要语言是TCL则无法通过将其翻译成TCL来轻松实现它。但是如果你的主要语言是Lisp那么通过翻译来实现其他东西并不困难。我们的想法是如果每个可扩展的应用程序都支持Scheme您可以在Scheme中编写TCL或Python或Perl的实现将该程序转换为Scheme。然后您可以将其加载到任何应用程序中并使用您喜欢的语言进行自定义它也可以与其他自定义项一起使用。
只要可扩展性语言很弱,用户就必须只使用您提供的语言。这意味着喜欢任何特定语言的人必须竞争应用程序开发人员的选择 - 说“请,应用程序开发人员,将我的语言放入您的应用程序,而不是他的语言。”然后用户根本没有选择 - 无论哪个他们正在使用的应用程序带有一种语言,并且它们被[该语言]所困扰。但是,如果你有一种强大的语言可以通过翻译来实现其他语言,那么你就可以让用户选择语言了,我们不再需要语言大战了。这就是我们希望'Guile'我们的计划翻译会做的。我们去年夏天有一个人在完成从Python到Scheme的翻译工作。我不知道是不是' 已完全完成,但对于对此项目感兴趣的任何人,请与我们联系。这就是我们未来的计划。
我没有谈过自由软件,但让我简要地告诉你一些关于这意味着什么的信息。自由软件不涉及价格; 这并不意味着你是免费获得的。(您可能已经支付了一份副本,或者免费获得了一份副本。)这意味着您拥有作为用户的自由。关键是你可以自由运行程序,自由学习它的功能,可以随意改变它以满足你的需求,可以自由地重新发布其他人的副本并免费发布改进的扩展版本。这就是自由软件的含义。如果你使用非免费程序,你就失去了至关重要的自由,所以不要这样做。
GNU项目的目的是通过提供免费软件来取代它使人们更容易拒绝自由践踏用户主导非自由软件。对于那些没有道德勇气拒绝非自由软件的人来说当这意味着一些实际的不便时我们试图做的是提供一个免费的替代方案这样你就可以在没有混乱的情况下转向自由。实际上的牺牲。牺牲越少越好。我们希望让您更轻松地生活在自由合作中。
这是合作自由的问题。我们习惯于思考自由和与社会的合作,好像他们是对立的。但在这里他们是在同一边。使用免费软件,您可以自由地与其他人合作,也可以自由地帮助自己。使用非自由软件,有人会主宰你并让人们分裂。你不能与他们分享,你不能自由地合作或帮助社会,而不是你可以自由地帮助自己。分裂和无助的是使用非自由软件的用户状态。
我们已经制作了大量的免费软件。我们做过人们说我们永远做不到的事情; 我们有两个免费软件操作系统。我们有很多应用程序显然我们还有很长的路要走。所以我们需要你的帮助。我想请你自愿参加GNU项目; 帮助我们开发更多工作的免费软件。看看 http://www.gnu.org/help 找到如何提供帮助的建议。如果您想订购商品,可以在主页上找到相关链接。如果你想阅读哲学问题,请查看/哲学。如果您正在寻找可以使用的免费软件,请查看/directory其中列出了大约1900个软件包这是所有免费软件的一小部分。请写更多信息并为我们做出贡献。我的论文“自由软件和自由社会”正在出售可以在www.gnu.org上购买。快乐的黑客
--------------------------------------------------------------------------------
via: https://www.gnu.org/gnu/rms-lisp.html
作者:[Richard Stallman][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[geekmar](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.gnu.org
[1]:https://www.gnu.org/help/
[2]:http://www.gnu.org/

View File

@ -1,199 +0,0 @@
不要安装 Yaourt在 Arch 上使用以下这些替代品。
======
**前略Yaourt 曾是最流行的 AUR 助手,但现已停止开发。在这篇文章中,我们会为 Arch 衍生发行版们列出 Yaourt 最佳的替代品。**
[Arch User Repository][1] 或者叫 AUR是一个为 Arch 用户而生的社区驱动软件仓库。Debian/Ubuntu 用户的对应类比是 PPA。
AUR 包含了不直接被 [Arch Linux][2] 官方所背书的软件。如果有人想在 Arch 上发布软件或者包,他可以通过 AUR 提供给客户。这让末端用户们可以使用到比默认仓库里更多的软件。
所以你该如何使用 AUR 呢?简单来说,你需要不同的工具以从 AUR 中安装软件。Arch 的包管理器 [pacman][3] 不直接支持 AUR。那些支持 AUR 的特殊工具我们称之为 [AUR Helpers][4]。
Yaourt (Yet AnOther User Repository Tool) 曾是一个以便于用户从 AUR 下载软件的, pacman 的再包装。他基本上使用和 pacman 一样的语法。Yaourt 对于 AUR 的搜索,安装,乃至冲突解决和包依赖都有着良好的支持。
然而Yaourt 的开发进度近来十分缓慢,甚至在 Arch Wiki 上已经被[列为][5]“停止或有问题”。[许多 Arch 用户认为它不安全][6] 进而开始寻找其他的 AUR 助手。
![Yaourt 以外的 AUR Helpers][7]
在这篇文章中,我们会介绍 Yaourt 最佳的替代品以便于你从 AUR 下载安装案件。
### AUR Helper 最好的选择
我刻意忽略掉了例如 Trizen 和 Packer 这样的选择,因为他们也被列为“停止或有问题”的了。
#### 1\. aurman
[aurman][8] 是最好的 AUR 助手之一,也能胜任 Yaourt 替代品。他对所有 pacman 的操作有着一样的语法。你可以搜索 AUR解决包依赖安装前检查 PKGBUILD 的内容等等。
##### aurman 的特性
* aurman 支持所有 pacman 操作并且引入了可靠的包依赖解决冲突判定和分包split package支持
* 分线程的 sudo 循环会在后来运行所以你每次安装只需要输入一次管理员密码
* 提供开发者包支持并且可以区分显性安装和隐性安装的包
* 支持搜索AUR
* 你可以检视并编辑 PKGBUILD 的内容
* 可以用作单独的 [包依赖解决][9]
##### 安装 aurman
```
git clone https://aur.archlinux.org/aurman.git
cd aurman
makepkg -si
```
##### 使用 aurman
用名字搜索:
```
aurman -Ss <package-name>
```
安装:
```
aurman -S &lt;package-name>
```
#### 2\. yay
[yay][10] 是我们列表上下一个选项。它使用 Go 语言写成,宗旨是提供 pacman 的界面并且让用户输入最少化yay 自己几乎没有任何依赖软件。
##### yay 的特性
* yay 提供 AUR 表格补全并且从 ABS 或 AUR 下载 PKGBUILD
* 支持收窄搜索,并且不需要引用 PKGBUILD 源
* yay 的二进制文件除了 pacman 以外别无依赖
* 提供先进的包依赖解决以及在编译安装之后移除编译时的依赖
* 支持日色彩输出,使用 /etc/pacman.conf 文件配置
* yay 可被配置成只支持 AUR 或者 repo 里的软件包
##### 安装 yay
你可以从 git 克隆并编译安装
```
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
```
##### 使用 yay
搜索:
```
yay -Ss <package-name>
```
安装:
```
yay -S <package-name>
```
#### 3\. pakku
[Pakku][11] 是另一个还在开发早期的 pacman 再包装,虽然它还处于开放早期,但这部说明它逊于其他任何 AUR 助手。Pakku 能良好地支持搜索和安安装,并且也可以在安装后移除不必要的编译依赖。
##### pakku 的特性
* 从 AUR 搜索安装软件
* 检视不同 build 之间的文件变化
* 从官方仓库编译并事后移除编译依赖
* 获取 PKGBUILD 以及 pacman 整合
* 类 pacman 的用户界面和选项支持
* 支持pacman 配置文件以及无需 PKGBUILD soucing
##### 安装 pakku
```
git clone https://aur.archlinux.org/pakku.git
cd pakku
makepkg -si
```
##### 使用 pakku
搜索:
```
pakku -Ss spotify
```
安装:
```
pakku -S spotify
```
#### 4\. aurutils
[aurutils][12] 本质上是一堆自动化脚本的集合。他可以搜索 AUR检查更新并且解决包依赖。
##### aurutils 的特性
* 不同的任务可以有多个仓库
* aursync -u 一键同步所有本地代码库
* aursearch 搜索提供 pkgbaselong format 和 raw 支持
* 能忽略指定包
##### 安装 aurutils
```
git clone https://aur.archlinux.org/aurutils.git
cd aurutils
makepkg -si
```
##### 使用 aurutils
搜索:
```
aurutils -Ss <package-name>
```
安装:
```
aurutils -S <package-name>
```
所有这些包,在有 Yaourt 或者其他 AUR 助手的情况下都可以直接安装。
#### 写在最后
Arch Linux 有着[很多 AUR 助手][4] 可以自动完成 AUR 各方面的日常任务。很多用户依然使用 Yaourt 来完成 AUR 相关任务,每个人都有自己不一样的偏好,欢迎留言告诉我们你在 Arch 里使用什么,又有什么心得?
--------------------------------------------------------------------------------
via: https://itsfoss.com/best-aur-helpers/
作者:[Ambarish Kumar][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[Moelf](https://github.com/Moelf)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://itsfoss.com/author/ambarish/
[1]:https://wiki.archlinux.org/index.php/Arch_User_Repository
[2]:https://www.archlinux.org/
[3]:https://wiki.archlinux.org/index.php/pacman
[4]:https://wiki.archlinux.org/index.php/AUR_helpers
[5]:https://wiki.archlinux.org/index.php/AUR_helpers#Comparison_table
[6]:https://www.reddit.com/r/archlinux/comments/4azqyb/whats_so_bad_with_yaourt/
[7]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/06/no-yaourt-arch-800x450.jpeg
[8]:https://github.com/polygamma/aurman
[9]:https://github.com/polygamma/aurman/wiki/Using-aurman-as-dependency-solver
[10]:https://github.com/Jguer/yay
[11]:https://github.com/kitsunyan/pakku
[12]:https://github.com/AladW/aurutils

View File

@ -0,0 +1,178 @@
查看一个归档或压缩文件的内容而无需解压它
======
![](https://www.ostechnix.com/wp-content/uploads/2018/07/View-The-Contents-Of-An-Archive-Or-Compressed-File-720x340.png)
在本教程中,我们将学习如何在类 Unix 系统中查看一个归档或者压缩文件的内容而无需实际解压它。在深入之前,让我们先厘清归档和压缩文件的概念,它们之间有显著不同。归档是将多个文件或者目录归并到一个文件的过程,因此这个生成的文件是没有被压缩过的。而压缩则是结合多个文件或者目录到一个文件并最终压缩这个文件的方法。归档文件不是一个压缩文件,但压缩文件可以是一个归档文件,清楚了吗?好,那就让我们进入今天的主题。
### 查看一个归档或者压缩文件的内容而无需解压它
得益于 Linux 社区,有很多命令行工具可以来达成上面的目标。下面就让我们来看看使用它们的一些示例。
**1 使用 Vim 编辑器**
Vim 不只是一个编辑器,使用它我们可以干很多事情。下面的命令展示的是在没有解压的情况下使用 Vim 查看一个压缩的归档文件的内容:
```
$ vim ostechnix.tar.gz
```
![][2]
你甚至还可以浏览归档文件的内容,打开其中的文本文件(假如有的话)。要打开一个文本文件,只需要用方向键将鼠标的游标放置到文件的前面,然后敲 ENTER 键来打开它。
**2 使用 Tar 命令**
为了列出一个 tar 归档文件的内容,可以运行:
```
$ tar -tf ostechnix.tar
ostechnix/
ostechnix/image.jpg
ostechnix/file.pdf
ostechnix/song.mp3
```
或者使用 **-v** 选项来查看归档文件的具体属性,例如它的文件所有者、属组、创建日期等等。
```
$ tar -tvf ostechnix.tar
drwxr-xr-x sk/users 0 2018-07-02 19:30 ostechnix/
-rw-r--r-- sk/users 53632 2018-06-29 15:57 ostechnix/image.jpg
-rw-r--r-- sk/users 156831 2018-06-04 12:37 ostechnix/file.pdf
-rw-r--r-- sk/users 9702219 2018-04-25 20:35 ostechnix/song.mp3
```
**3 使用 Rar 命令**
要查看一个 rar 文件的内容,只需要执行:
```
$ rar v ostechnix.rar
RAR 5.60 Copyright (c) 1993-2018 Alexander Roshal 24 Jun 2018
Trial version Type 'rar -?' for help
Archive: ostechnix.rar
Details: RAR 5
Attributes Size Packed Ratio Date Time Checksum Name
----------- --------- -------- ----- ---------- ----- -------- ----
-rw-r--r-- 53632 52166 97% 2018-06-29 15:57 70260AC4 ostechnix/image.jpg
-rw-r--r-- 156831 139094 88% 2018-06-04 12:37 C66C545E ostechnix/file.pdf
-rw-r--r-- 9702219 9658527 99% 2018-04-25 20:35 DD875AC4 ostechnix/song.mp3
----------- --------- -------- ----- ---------- ----- -------- ----
9912682 9849787 99% 3
```
**4 使用 Unrar 命令**
你也可以使用带有 **l** 选项的 **Unrar** 来做到与上面相同的事情,展示如下:
```
$ unrar l ostechnix.rar
UNRAR 5.60 freeware Copyright (c) 1993-2018 Alexander Roshal
Archive: ostechnix.rar
Details: RAR 5
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 53632 2018-06-29 15:57 ostechnix/image.jpg
-rw-r--r-- 156831 2018-06-04 12:37 ostechnix/file.pdf
-rw-r--r-- 9702219 2018-04-25 20:35 ostechnix/song.mp3
----------- --------- ---------- ----- ----
9912682 3
```
**5 使用 Zip 命令**
为了查看一个 zip 文件的内容而无需解压它,可以使用下面的 **zip** 命令:
```
$ zip -sf ostechnix.zip
Archive contains:
Life advices.jpg
Total 1 entries (597219 bytes)
```
**6. 使用 Unzip 命令**
你也可以像下面这样使用 **-l** 选项的 **Unzip** 命令来呈现一个 zip 文件的内容:
```
$ unzip -l ostechnix.zip
Archive: ostechnix.zip
Length Date Time Name
--------- ---------- ----- ----
597219 2018-04-09 12:48 Life advices.jpg
--------- -------
597219 1 file
```
**7 使用 Zipinfo 命令**
```
$ zipinfo ostechnix.zip
Archive: ostechnix.zip
Zip file size: 584859 bytes, number of entries: 1
-rw-r--r-- 6.3 unx 597219 bx defN 18-Apr-09 12:48 Life advices.jpg
1 file, 597219 bytes uncompressed, 584693 bytes compressed: 2.1%
```
如你所见,上面的命令展示了一个 zip 文件的内容、它的权限、创建日期和压缩百分比等等信息。
**8. 使用 Zcat 命令**
要一个压缩的归档文件的内容而不解压它,使用 **zcat** 命令,我们可以得到:
```
$ zcat ostechnix.tar.gz
```
zcat 和 `gunzip -c` 命令相同。所以你可以使用下面的命令来查看归档或者压缩文件的内容:
```
$ gunzip -c ostechnix.tar.gz
```
**9. 使用 Zless 命令**
要使用 Zless 命令来查看一个归档或者压缩文件的内容,只需:
```
$ zless ostechnix.tar.gz
```
这个命令类似于 `less` 命令,它将一页一页地展示其输出。
**10. 使用 Less 命令**
可能你已经知道 **less** 命令可以打开文件来交互式地阅读它,并且它支持滚动和搜索。
运行下面的命令来使用 less 命令查看一个归档或者压缩文件的内容:
```
$ less ostechnix.tar.gz
```
上面便是全部的内容了。现在你知道了如何在 Linux 中使用各种命令查看一个归档或者压缩文件的内容了。希望本文对你有用。更多好的内容将呈现给大家,希望继续关注我们!
干杯!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-view-the-contents-of-an-archive-or-compressed-file-without-extracting-it/
作者:[SK][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[FSSlc](https://github.com/FSSlc)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.ostechnix.com/author/sk/
[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[2]:http://www.ostechnix.com/wp-content/uploads/2018/07/vim.png

View File

@ -1,224 +1,131 @@
A gawk script to convert smart quotes
一个转换花引号的 gawk 脚本
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_520x292_opensourceprescription.png?itok=gFrc_GTH)
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_520x292_opensourceprescription.pngitok=gFrc_GTH)
I manage a personal website and edit the web pages by hand. Since I don't have many pages on my site, this works well for me, letting me "scratch the itch" of getting into the site's code.
我管理着一个个人网站,同时手工编辑网站上的网页。由于网站上的页面并不多,这种方法对我很适合,可以让我对网站代码的细节一清二楚。
When I updated my website's design recently, I decided to turn all the plain quotes into "smart quotes," or quotes that look like those used in print material: “” instead of "".
最近我升级了网站的设计样式,我决定把所有的普通引号都转换成 "花引号",即在打印材料中使用的那种引号:用 “” 来代替 ""。
Editing all of the quotes by hand would take too long, so I decided to automate the process of converting the quotes in all of my HTML files. But doing so via a script or program requires some intelligence. The script needs to know when to convert a plain quote to a smart quote, and which quote to use.
手工修改所有的引号太耗时了,因此我决定将转换所有 HTML 文件中引号的过程自动化。不过通过程序或脚本来实现该功能需要费点劲。这个脚本需要知道何时将普通引号转换成花引号,并决定使用哪种引号(译注:左引号还是右引号,单引号还是双引号)。
You can use different methods to convert quotes. Greg Pittman wrote a [Python script][1] for fixing smart quotes in text. I wrote mine in GNU [awk][2] (gawk).
有多种方法可以转换引号。Greg Pittman 写过一个 [Python 脚本 ][1] 来修正文本中的花引号。而我自己使用 GNU [awk][2] (gawk) 来实现。
> Get our awk cheat sheet. [Free download][3].
> 下载我的 awk 备忘录。[免费下载 ][3]。
To start, I wrote a simple gawk function to evaluate a single character. If that character is a quote, the function determines if it should output a plain quote or a smart quote. The function looks at the previous character; if the previous character is a space, the function outputs a left smart quote. Otherwise, the function outputs a right smart quote. The script does the same for single quotes.
开始之前,我写了一个简单的 gawk 函数来评估单个字符。若该字符是一个引号,这该函数判断是输出普通引号还是花引号。函数查看前一个字符; 若前一个字符是空格,则函数输出左花引号。否则函数输出右花引号。脚本对单引号的处理方式也一样。
```
function smartquote (char, prevchar) {
        # print smart quotes depending on the previous character
        # otherwise just print the character as-is
        if (prevchar ~ /\s/) {
                # prev char is a space
                if (char == "'") {
                        printf("&lsquo;");
                }
                else if (char == "\"") {
                        printf("&ldquo;");
                }
                else {
                        printf("%c", char);
                }
        }
        else {
                # prev char is not a space
                if (char == "'") {
                        printf("&rsquo;");
                }
                else if (char == "\"") {
                        printf("&rdquo;");
                }
                else {
                        printf("%c", char);
                }
        }
}
```
With that function, the body of the gawk script processes the HTML input file character by character. The script prints all text verbatim when inside an HTML tag (for example, `<html lang="en">`. Outside any HTML tags, the script uses the `smartquote()` function to print text. The `smartquote()` function does the work of evaluating when to print plain quotes or smart quotes.
这个 gawk 脚本的主体部分通过该函数处理 HTML 输入文件的一个个字符。该脚本在 HTML 标签内部逐字原样输出所有内容(比如,`<html lang="en">`)。在 HTML 标签外,脚本使用 `smartquote()` 函数来输出文本。`smartquote()` 函数来评估是输出普通引号还是花引号。
```
function smartquote (char, prevchar) {
        ...
}
BEGIN {htmltag = 0}
{
        # for each line, scan one letter at a time:
        linelen = length($0);
        prev = "\n";
        for (i = 1; i <= linelen; i++) {
                char = substr($0, i, 1);
                if (char == "<") {
                        htmltag = 1;
                }
                if (htmltag == 1) {
                        printf("%c", char);
                }
                else {
                        smartquote(char, prev);
                        prev = char;
                }
                if (char == ">") {
                        htmltag = 0;
                }
        }
        # add trailing newline at end of each line
        printf ("\n");
}
```
Here's an example:
下面是一个例子:
```
gawk -f quotes.awk test.html > test2.html
```
Sample input:
其输入为:
```
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Test page</title>
  <link rel="stylesheet" type="text/css" href="/test.css" />
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width" />
</head>
<body>
  <h1><a href="/"><img src="logo.png" alt="Website logo" /></a></h1>
  <p>"Hi there!"</p>
  <p>It's and its.</p>
</body>
</html>
```
Sample output:
其输出为:
```
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Test page</title>
  <link rel="stylesheet" type="text/css" href="/test.css" />
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width" />
</head>
<body>
  <h1><a href="/"><img src="logo.png" alt="Website logo" /></a></h1>
  <p>&ldquo;Hi there!&rdquo;</p>
  <p>It&rsquo;s and its.</p>
</body>
</html>
```
--------------------------------------------------------------------------------
@ -227,12 +134,12 @@ via: https://opensource.com/article/18/8/gawk-script-convert-smart-quotes
作者:[Jim Hall][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/jim-hall
[1]:https://opensource.com/article/17/3/python-scribus-smart-quotes
[2]:/downloads/cheat-sheet-awk-features
[2]:https://opensource.com/downloads/cheat-sheet-awk-features
[3]:https://opensource.com/downloads/cheat-sheet-awk-features