Introduce a conceptual help topic about calling external programs (native applications)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- powershell
调研方向
首先查看 about_Parsing、about_Quoting_Rules、about_Redirection、about_Pipelines、about_pwsh 和 about_Operators,以及相关 issue 和 RFC。为 about_* 部分起草拟议的 about_Native_Calls 主题,涵盖列出的原生程序行为并链接到这些文章;完成的标准是已添加完整的指导内容并将其纳入 TOC。
由索引模型根据 Issue 内容生成。
描述
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 incmd.exeandbash, you must use'@foo'in PowerShell).- How
--%can be used (primarily on Windows) to selectively deactivate PowerShell's parsing.
- How
-
How "native globbing" is automatically applied to arguments such as
*.txton Unix-like platforms; that is,*.txtis 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]::OutputEncodingencoded 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
$?/$LASTEXITCODEto 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-Processis 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
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MicrosoftDocs/PowerShell-Docs 的其他 Issue
-
issue-doc-idea needs-triage
难度 2/5 1-2 天 新手友好度 86/100
MicrosoftDocs/PowerShell-Docs#13306 ·
维护者通常 1 天内回复
-
needs-triage
难度 1/5 1 小时以内 新手友好度 78/100
MicrosoftDocs/PowerShell-Docs#13305 ·
维护者通常 1 天内回复
-
hold-for-pr hold-for-release issue-doc-idea
难度 2/5 1-3 小时 新手友好度 68/100
MicrosoftDocs/PowerShell-Docs#13195 ·
维护者通常 1 天内回复
-
hold-for-pr hold-for-release
难度 1/5 1 小时以内 新手友好度 88/100
MicrosoftDocs/PowerShell-Docs#12897 ·
维护者通常 1 天内回复
-
Add "Avoid function / scriptblock based recursion" section to `Performance Considerations` document未关闭area-sdk-docs
难度 2/5 1-3 小时 新手友好度 72/100
MicrosoftDocs/PowerShell-Docs#11037 · 1 个 reaction ·
维护者通常 1 天内回复
查看 MicrosoftDocs/PowerShell-Docs 的全部 Issue
相似的 Issue
-
sync-en
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
ACK_WAITING HELP_WANTED UPDATE_CS
难度 2/5 1-3 小时 新手友好度 78/100
OWASP/CheatSheetSeries#2458 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
l3montree-dev/devguard#3101 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复
-
area/documentation status/need-triage
难度 1/5 1 小时以内 新手友好度 95/100
google-gemini/gemini-cli#29548 ·
维护者通常 1 天内回复