全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Pathname expansion, quoting, word splitting?

又称: pathname expansion · word splitting · quoting

Definition 8.8 University Computer Science — Year 1 · 第 8 章 — The Shell

Pathname expansion replaces a word containing * (any string), ? (any one character) or [...] (one character of a set) by the sorted names of the files that match it, a glob; a pattern that matches nothing is left as it is, and names starting with a dot are matched only by a pattern starting with a dot. Word splitting cuts the result of an unquoted variable expansion into several words at spaces, tabs and newlines. Quoting suspends both: between single quotes every character is literal; between double quotes $ still expands variables but no splitting or pathname expansion happens; a backslash makes the next character literal.

The order in which the shell rewrites a command line (the tilde ~ is expanded with the variables). Quotes act at every step, braces included, and are removed last: that is why "$f" reaches the program as one word with the variable’s value, spaces and all.
The order in which the shell rewrites a command line (the tilde ~ is expanded with the variables). Quotes act at every step, braces included, and are removed last: that is why "$f" reaches the program as one word with the variable’s value, spaces and all.
在原文中阅读 →