Closed Hashbrown777 closed 4 days ago
Is this a duplicate of #21402 ?
Is this a duplicate of #21402 ?
Looks like it.
They need to update the title with the real cause of the issue; the calling name ($args[0]
in other languages, eg $0
in bash) is missing the .ps1
is the cause.
Seems it's not so much the name of the actual script itself.
Keeping it "Symbolic links can change..." is impossible to search if you're closer to the real problem à la "...script missing .ps1 extension".
To add; I think what's really responsible is that $MyInvocation
has .MyCommand
listed as the whole script as a raw string, instead of the script as a file, when the extension is missing.
If MyCommand
isn't a file it cannot have a path.
Dup #4217
Dup #4217
Can't dupe a closed-due-to-inactivity issue.
"if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you"
#!/bin/sh -e
exec pwsh -File "$0.ps1" "$@"
I've just resorted to keeping the .ps1
on the actual script instead of pushing args and input&output streams through an intermediary, and hopefully this'll get fixed one day.
It took forever for something huge like 1908 to get done, but it did get done!
instead of pushing input&output streams through an intermediary
Just so you know, the exec means no fork occurs and pwsh replaces sh with the same process id, environment, file descriptors etc. There is no intermediate.
!/bin/sh -e
It's more bourne itself, I don't want to have to look up the intricacies of $@
et cetera and any caveats involved with explicitly using pwsh's -File
, even if it turns out there are none for either. It's much simpler to just rename the script for now.
This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.
📣 Hey @Hashbrown777, how did we do? We would love to hear your feedback with the link below! 🗣️
🔗 https://aka.ms/PSRepoFeedback
Prerequisites
Steps to reproduce
Create a script utilising
$PSScriptRoot
, running via crunchbang instead of file association.Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals