为什么Windows PowerShell命令称为Cmdlet?

为什么Windows PowerShell命令称为Cmdlet?_第1张图片

When working with Windows PowerShell, you may have come across the term cmdlet and found yourself somewhat confused. Is a cmdlet something totally different from a command or is it just the PowerShell name for them? Today’s SuperUser Q&A post has the answer to a curious reader’s question.

使用Windows PowerShell时,您可能遇到过cmdlet这个词,并发现自己有些困惑。 cmdlet与命令完全不同还是仅仅是它们的PowerShell名称? 今天的“超级用户问答”帖子回答了一个好奇的读者的问题。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader RBT wants to know why Windows PowerShell commands are called cmdlets:

超级用户阅读器RBT想知道为什么Windows PowerShell命令称为cmdlet:

I have been trying to figure out the nomenclature for why commands are called command-lets (cmdlets) in PowerShell. Why they are not simply called commands instead? What is the difference?

我一直在试图弄清楚为什么在PowerShell中将命令称为command-let(cmdlet)的术语。 为什么它们不简单地称为命令? 有什么不同?

I could only guess based on this Wikipedia article about PowerShell that it might somehow be an abbreviation of the command line interface to interact with commands written in .Net.

我只能根据有关PowerShell的Wikipedia文章猜测,以某种方式它可能是与.Net编写的命令进行交互的命令行界面的缩写。

Why are Windows PowerShell commands called cmdlets?

为什么Windows PowerShell命令称为cmdlet?

答案 (The Answer)

SuperUser contributor LotPings has the answer for us:

超级用户贡献者LotPings为我们提供了答案:

According to Microsoft:

根据微软的说法:

A cmdlet is a lightweight command that is used in the Windows PowerShell environment. The Windows PowerShell runtime invokes these cmdlets within the context of automation scripts that are provided at the command line. The Windows PowerShell runtime also invokes them programmatically through Windows PowerShell APIs.

cmdlet是Windows PowerShell环境中使用的轻量级命令。 Windows PowerShell运行时在命令行提供的自动化脚本的上下文中调用这些cmdlet。 Windows PowerShell运行时还通过Windows PowerShell API以编程方式调用它们。

How Cmdlets Differ from Commands

Cmdlet与命令有何不同

Cmdlets differ from commands in other command-shell environments in the following ways:

Cmdlet与其他命令外壳程序环境中的命令在以下方面有所不同:

  • Cmdlets are instances of .NET Framework classes; they are not stand-alone executables.

    Cmdlet是.NET Framework类的实例; 它们不是独立的可执行文件。
  • Cmdlets can be created from as few as a dozen lines of code.

    Cmdlet可以用十几行代码创建。
  • Cmdlets do not generally do their own parsing, error presentation, or output formatting. Parsing, error presentation, and output formatting are handled by the Windows PowerShell runtime.

    Cmdlet通常不进行自己的解析,错误表示或输出格式化。 解析,错误表示和输出格式由Windows PowerShell运行时处理。
  • Cmdlets process input objects from the pipeline rather than from streams of text, and cmdlets typically deliver objects as output to the pipeline.

    Cmdlet从管道而不是从文本流处理输入对象,而cmdlet通常将对象作为输出传递到管道。
  • Cmdlets are record-oriented because they process a single object at a time.

    Cmdlet是面向记录的,因为它们一次处理一个对象。

Source: Cmdlet Overview [Microsoft]

来源: Cmdlet概述 [Microsoft]



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程 。

翻译自: https://www.howtogeek.com/302060/why-are-windows-powershell-commands-called-cmdlets/

你可能感兴趣的:(python,linux,java,shell,编程语言)