Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Introduce a conceptual help topic about calling external programs (native applications)

未关闭
#5,152 6 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
powershell
领域
documentation

调研方向

首先查看 about_Parsing、about_Quoting_Rules、about_Redirection、about_Pipelines、about_pwsh 和 about_Operators,以及相关 issue 和 RFC。为 about_* 部分起草拟议的 about_Native_Calls 主题,涵盖列出的原生程序行为并链接到这些文章;完成的标准是已添加完整的指导内容并将其纳入 TOC。

由索引模型根据 Issue 内容生成。

描述

area-about area-conceptual area-native-cmds issue-doc-idea

Related: #2361, https://github.com/PowerShell/PowerShell/issues/13068#issuecomment-653526374, and #6239

Summary of the new document or enhancement

Many special considerations apply when you call an external command-line executable (aka native application / utility), which aren't currently covered comprehensively, in one place:

  • That the only data type supported is text ([string]), both on input and output, and how raw byte data is fundamentally unsupported - both when collecting the output in PowerShell and when piping between native programs.

    • Update: v7.4 introduced raw byte support.
  • How there are syntax pitfalls due to PowerShell's extended set of metacharacters (compared to other shells) causing potential misinterpretation of arguments, which must be avoided with quoting (e.g., To pass literal @foo, which works unquoted in cmd.exe and bash, you must use '@foo' in PowerShell).

    • How --% can be used (primarily on Windows) to selectively deactivate PowerShell's parsing.
  • How "native globbing" is automatically applied to arguments such as *.txt on Unix-like platforms; that is, *.txt is implicitly replaced with the array of file names / paths matching that wildcard pattern.

  • How output data is sent through the pipeline line by line, resulting in an array of strings (lines), if collected in a variable.

  • How stderr (standard error) output is passed through to the host rather than going through PowerShell's error stream and can only be captured with a 2> redirection.

  • How redirections (>) generally do not pass the native program's output through as-is, but invariably treat it as [Console]::OutputEncoding encoded text that on writing to the target file is written with PowerShell's default encoding (BOM-less UTF-8 in PowerShell 6+, UTF-16LE in Windows PowerShell).

  • How external-program calls aren't integrated with PowerShell's error handling and require explicit checking of $? / $LASTEXITCODE to detect failure, except in PowerShell 7, where pipeline chain operators && and || can now be used. See also: the RFC that proposes improvements to the integration.

  • How &, the call operator, must be used to invoke executables whose paths are / must be quoted (as a whole) and/or contain variable references or subexpressions (this requirement isn't specific to external programs, but most likely to surface in that context).

  • How Start-Process is typically not the right tool for invoking external programs - see #6239.

Details of requested document:

  • Proposed title: about_Native_Calls
  • Propose location in the TOC: Among the `about_* topics
  • Target audience: end users
  • Purpose or scenario: guidance for invoking native command-line programs
  • List of related articles to link to: about_Parsing, about_Quoting_Rules, about_Redirection, about_Pipelines, about_pwsh, about_Operators (section "Pipeline chain operators && and ||")
主要语言
PowerShell
星标
2.5k
派生
1.7k
平均合并
6 小时 58 分钟
30 天内合并 PR
31

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MicrosoftDocs/PowerShell-Docs 的其他 Issue

查看 MicrosoftDocs/PowerShell-Docs 的全部 Issue

相似的 Issue

更多 Documentation Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。