René's URL Explorer Experiment


Title: CLI: Stdin input does not implicitly become pipeline input · Issue #9497 · PowerShell/PowerShell · GitHub

Open Graph Title: CLI: Stdin input does not implicitly become pipeline input · Issue #9497 · PowerShell/PowerShell

X Title: CLI: Stdin input does not implicitly become pipeline input · Issue #9497 · PowerShell/PowerShell

Description: Currently, stdin input streamed to pwsh from the outside: does not automatically become pipeline input; accessing stdin input currently requires constructing a separate pipeline in PowerShell code using $Input only automatically becomes ...

Open Graph Description: Currently, stdin input streamed to pwsh from the outside: does not automatically become pipeline input; accessing stdin input currently requires constructing a separate pipeline in PowerShell code ...

X Description: Currently, stdin input streamed to pwsh from the outside: does not automatically become pipeline input; accessing stdin input currently requires constructing a separate pipeline in PowerShell code ...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/9497

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CLI: Stdin input does not implicitly become pipeline input","articleBody":"Currently, _stdin_ input streamed to `pwsh` _from the outside_:\r\n\r\n* does _not_ automatically become pipeline input;\r\n  * accessing stdin input currently requires constructing a separate pipeline in PowerShell code using `$Input`\r\n\r\n* only automatically becomes input to _interactive prompts_, such as `Read-Host` calls or the automatic prompts displayed when mandatory arguments are missing.\r\n\r\nThis has the following implications:\r\n\r\n**You cannot directly pipe data to PowerShell commands from the outside:**\r\n\r\nContrast the following two commands:\r\n\r\n```sh\r\n# Bash:\r\n# stdin input is \"relayed\" to the 'wc' utility\r\n$ printf 'one\\ntwo' | bash -c 'wc'\r\n2\r\n```\r\n\r\n```powershell\r\n# PowerShell:\r\nPS> printf 'one\\ntwo' | pwsh -noprofile -c 'Measure-Object -Word | % Words'\r\n0 # !! Measure-Object did NOT receive stdin input.\r\n\r\n# Explicit reference to $Input in an internal pipeline is required:\r\nPS> printf 'one\\ntwo\\n' | pwsh -noprofile -c '$Input | Measure-Object -Word | % Words'\r\n2\r\n```\r\nprintf 'one\\ntwo\\n' | pwsh -noprofile -c 'Measure-Object -Word'\r\n\r\n**If you're calling an _advanced script that binds pipeline input_, it cannot be invoked with just `-File`, because it won't receive pipeline input**:\r\n\r\n```powershell\r\n# Create an advanced script that echoes each pipeline input enclosed in [...]\r\n'[CmdletBinding()] param([Parameter(ValueFromPipeline)] $var) process { \"[$var]\" }' > t.ps1\r\n\r\n# Call from either Bash or PowerShell (same behavior).\r\nPS> echo hi | pwsh -noprofile -file t.ps1\r\n[]  # !! t.ps1 did NOT receive stdin input\r\n\r\n# The workaround is again non-obvious and cumbersome:\r\nPS> echo hi | pwsh -noprofile -command '$Input | ./t.ps1'\r\n[hi]  # OK\r\n```\r\n\r\n**Similarly, if you author a pipeline-binding advanced script as _shebang-line-based script on Unix_, it cannot receive stdin input directly**:\r\n\r\n```powershell\r\n# Create a shebang-line-based script...\r\n@'\r\n#!/usr/bin/env pwsh\r\n[CmdletBinding()] param([Parameter(ValueFromPipeline)] $var) process { \"[$var]\" }\r\n'@ > foo\r\n\r\n# ... and make it executable.\r\nchmod +x foo\r\n\r\n# Call from either Bash or PowerShell (same behavior).\r\nPS> 1..2 | ./foo\r\n[]  # !! Pipeline input wasn't bound, not even with pipeline input from PowerShell.\r\n``` \r\n\r\n---\r\n\r\nPowerShell's behavior here is at odds with traditional shells and arguably makes the typical use case unnecessarily difficult.\r\n\r\nNote: **I'm unclear on whether this can be fixed without breaking existing behavior.**\r\n\r\nThe challenge is to know when to provide stdin input via an _implied PowerShell pipeline_, and when to use stdin input line by line, on demand, to respond to _interactive prompts_.\r\n\r\nE.g., the following currently works - the two distinct `Read-Host` prompts are \"answered\" by 1 stdin input line each:\r\n\r\n```powershell\r\n$ 'one\\ntwo\\n' | pwsh -noprofile -c 'read-host first; get-date;  read-host second'\r\nfirst: one\r\none\r\n\r\nMonday, April 29, 2019 10:52:04 AM\r\nsecond: two\r\ntwo\r\n```\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core 6.2.0\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-04-29T15:05:19Z","url":"https://github.com/PowerShell/PowerShell/issues/9497"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:574a28fa-f10d-9fd2-71e4-55c54cf8b19e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC462:160FD0:26473C0:35511D9:6AFD4303
html-safe-nonce7b7c17780640d1d283eae49e39df087a0829422fd4911ab242d6495151747530
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDYyOjE2MEZEMDoyNjQ3M0MwOjM1NTExRDk6NkFGRDQzMDMiLCJ2aXNpdG9yX2lkIjoiMTI0MTk3NTAxMTg3OTUwMjU5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac26a609d57ac2ed4f1048fe438de06a75908c3156db8b380a5edd25f0b12ae92f
hovercard-subject-tagissue:438363576
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/9497/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0cf304241c03a759be1c66d7ca4083dd3469b90ee1fe5fd2f377643b7e668151/PowerShell/PowerShell/issues/9497
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0cf304241c03a759be1c66d7ca4083dd3469b90ee1fe5fd2f377643b7e668151/PowerShell/PowerShell/issues/9497
og:image:altCurrently, stdin input streamed to pwsh from the outside: does not automatically become pipeline input; accessing stdin input currently requires constructing a separate pipeline in PowerShell code ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemklement0
hostnamegithub.com
expected-hostnamegithub.com
Nonebdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release556dd37bb0aceffb25724e151b5d858b3265b40b
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/9497#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F9497
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F9497
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/9497
Reloadhttps://github.com/PowerShell/PowerShell/issues/9497
Reloadhttps://github.com/PowerShell/PowerShell/issues/9497
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests364 (364)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
https://github.com/PowerShell/PowerShell
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/9497
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/9497
CLI: Stdin input does not implicitly become pipeline inputhttps://github.com/PowerShell/PowerShell/issues/9497#top
Issue-Enhancementthe issue is more of a feature request than a bughttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Enhancement%22
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Apr 29, 2019https://github.com/PowerShell/PowerShell/issues/9497#issue-438363576
Michael Klement (mklement0)https://github.com/mklement0
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
on Apr 29, 2019https://github.com/PowerShell/PowerShell/issues/9497#event-2306990521
Travis Plunk (TravisEz13)https://github.com/TravisEz13
Issue-Enhancementthe issue is more of a feature request than a bughttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Enhancement%22
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get ahttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Question%22
on Apr 29, 2019https://github.com/PowerShell/PowerShell/issues/9497#event-2307426476
https://github.com/bergmeister
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Nov 14, 2019https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-553868521
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Nov 14, 2019https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-553871905
https://github.com/bergmeister
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Nov 14, 2019https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-553873540
https://github.com/mvalikar
mvalikarhttps://github.com/mvalikar
on Dec 18, 2019https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-566838420
Christoph Bergmeister (@bergmeister)https://github.com/bergmeister
https://github.com/bergmeister
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Dec 18, 2019https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-566924419
mvalikarhttps://github.com/mvalikar
https://docs.databricks.com/dev-tools/cli/index.htmlhttps://docs.databricks.com/dev-tools/cli/index.html
https://github.com/PowerShell/_static/favicon.ico
Databricks CLI — Databricks Documentationhttps://docs.databricks.com/dev-tools/cli/index.html
Steve Lee (SteveL-MSFT)https://github.com/SteveL-MSFT
Futurehttps://github.com/PowerShell/PowerShell/milestone/48
on May 26, 2020https://github.com/PowerShell/PowerShell/issues/9497#event-3374156314
https://github.com/jiasli
Jiashuo Li (jiasli)https://github.com/jiasli
on Sep 14, 2022https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1246179450
$inputhttps://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.2#input
https://github.com/jiasli
Jiashuo Li (jiasli)https://github.com/jiasli
on Sep 14, 2022https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1246338213
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Sep 14, 2022https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1246868510
Don’t parse the pipeline as text when it is directed from an EXE to another EXE or file. Keep the bytes as-is. #1908https://github.com/PowerShell/PowerShell/issues/1908
https://github.com/jiasli
Jiashuo Li (jiasli)https://github.com/jiasli
on Sep 15, 2022https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1247542207
Michael Klement (@mklement0)https://github.com/mklement0
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Sep 15, 2022https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1247745380
https://github.com/pcgeek86
Trevor Sullivan (pcgeek86)https://github.com/pcgeek86
on Jan 14, 2023https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1382624972
https://user-images.githubusercontent.com/466713/212444289-ebd14ff8-e356-4ec7-9b36-8d1554159406.png
https://user-images.githubusercontent.com/466713/212444362-77a70984-5cf3-42ad-ac9d-ccf68400e414.png
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/9497#event-10976106403
https://github.com/pcgeek86
Trevor Sullivan (pcgeek86)https://github.com/pcgeek86
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1814812668
https://private-user-images.githubusercontent.com/466713/283527227-72ff8536-c34b-4e48-995b-a44513ccb902.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTQ5ODI5NjAsIm5iZiI6MTc5NDk4MjY2MCwicGF0aCI6Ii80NjY3MTMvMjgzNTI3MjI3LTcyZmY4NTM2LWMzNGItNGU0OC05OTViLWE0NDUxM2NjYjkwMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYxMTE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MTExOFQwNjE3NDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hNTEzMjIzMDhjZjFmZGMxNzAxZjc2MTZhZmUyYzBiNWM0NGFkZGUxZWU5MTNlZTQ5Nzc4MGM5ZTM5ZTM1MDE4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.6IXb796MM2TCOsb0mS-DWgRzFX57c3yBsPHRAZowFS4
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
Futurehttps://github.com/PowerShell/PowerShell/milestone/48
on Nov 24, 2023https://github.com/PowerShell/PowerShell/issues/9497#event-11051759524
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
completedhttps://github.com/PowerShell/PowerShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 24, 2023https://github.com/PowerShell/PowerShell/issues/9497#event-11051759541
https://github.com/fireflycons
Alistair Mackay (fireflycons)https://github.com/fireflycons
on Dec 4, 2023https://github.com/PowerShell/PowerShell/issues/9497#issuecomment-1837928372
Trevor Sullivan (@pcgeek86)https://github.com/pcgeek86
https://github.com/fireflycons/git-hook-dispatcherhttps://github.com/fireflycons/git-hook-dispatcher
https://camo.githubusercontent.com/226bb06e8eb4f0563c715f4ee08754a5e7f6b3eed5e2b66d5a6e05130a78966d/68747470733a2f2f6f70656e67726170682e6769746875626173736574732e636f6d2f393136643962386333613134633238663964316262313834323236373536633833653839376333653431356666326365653633326565393839636438613138362f66697265666c79636f6e732f6769742d686f6f6b2d64697370617463686572
https://camo.githubusercontent.com/7e41d4698b37a89b2a8c06057583a5f48ce614b0fb7e2b93d27a2ec01c8f024b/68747470733a2f2f6769746875622e6769746875626173736574732e636f6d2f66617669636f6e732f66617669636f6e2e737667
GitHub - fireflycons/git-hook-dispatcher: Git hooks for Windows - native without git-bash etc.https://github.com/fireflycons/git-hook-dispatcher
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
on Dec 4, 2023https://github.com/PowerShell/PowerShell/issues/9497#event-11134690663
github-project-automationhttps://github.com/apps/github-project-automation
Shellhttps://github.com/orgs/PowerShell/projects/31
on Aug 28, 2024https://github.com/PowerShell/PowerShell/issues/9497#event-14723759052
github-project-automationhttps://github.com/apps/github-project-automation
Shellhttps://github.com/orgs/PowerShell/projects/31
on Aug 28, 2024https://github.com/PowerShell/PowerShell/issues/9497
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PowerShell/issues/9497
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/9497
Issue-Enhancementthe issue is more of a feature request than a bughttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Enhancement%22
Shellhttps://github.com/orgs/PowerShell/projects/31
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.