Code Monkey home page Code Monkey logo

Comments (10)

rhubarb-geek-nz avatar rhubarb-geek-nz commented on June 6, 2024 1

Is this a duplicate of #21402 ?

from powershell.

Hashbrown777 avatar Hashbrown777 commented on June 6, 2024 1

#!/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.

from powershell.

Hashbrown777 avatar Hashbrown777 commented on June 6, 2024

Is this a duplicate of #21402 ?
image

Looks like it.

image
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.
image

from powershell.

iSazonov avatar iSazonov commented on June 6, 2024

Dup #4217

from powershell.

Hashbrown777 avatar Hashbrown777 commented on June 6, 2024

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"

from powershell.

rhubarb-geek-nz avatar rhubarb-geek-nz commented on June 6, 2024

#21402 did have a work around, creating a shell script without the extension adjacent to the powershell script with ps1

#!/bin/sh -e
exec pwsh -File "$0.ps1" "$@"

from powershell.

Hashbrown777 avatar Hashbrown777 commented on June 6, 2024

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!

from powershell.

rhubarb-geek-nz avatar rhubarb-geek-nz commented on June 6, 2024

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.

from powershell.

microsoft-github-policy-service avatar microsoft-github-policy-service commented on June 6, 2024

This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.

from powershell.

microsoft-github-policy-service avatar microsoft-github-policy-service commented on June 6, 2024

📣 Hey @Hashbrown777, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

from powershell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.