-
Notifications
You must be signed in to change notification settings - Fork 7.6k
#!/usr/local/bin/powershell bang should not load profile #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ha! I don't see anyway this is going to work without a shim that executes with |
We just need to figure out who called us, you know. Also, if you run the same way #!powershell
Write-Host 'foo'
|
I don't see how we would reliably determine who called us, and how to interpret it (I as a user might call PowerShell via I think really we just want to run with This would be much better behavior (but we'd need a way to specify |
@lzybkr can you comment on the profile/noprofile, please ? Should this work at all |
I just noticed this in my .bashrc:
So I would say we should run the profile with |
👍 |
Since #3558 merged it seems we can get a fix for this. |
Note: In this discussion, we're equating PowerShell profiles with one type of initialization file in POSIX-like shells, the "individual per-interactive-shell startup file", as Bash calls it, stored in
|
Here's how Bash determines if an instance is non-interactive - such as when invoked via a shebang line (as stated, non-interactive instances by default do not load any initialization files):
Note that the use of shebang line |
Interesting, if we install PowerShell in different locations across supported Unix platforms why not create a link to current version in
|
At least Linux platforms conform to the FHS (Filesystem Hierarchy Standard), according to which placing a symlink to the PowerShell binary in
Probably yes, but how does that come into play here?
You can always do that from within a script, if needed; e.g.,
That seems like an obscure and cumbersome workaround. |
If we want to be bash-behaivor-compatible we should use bash startup code and embed it in PowerShell startup code. But it doesn't seem compatible with PowerShell behavior. Dead lock :-). I think we're doomed to be rude and break a wall somewhere. Until we have the right solution, I prefer to have a wrapper. When it becomes stable, we could gradually embed it in the main code. |
@mklement0 3720 was closed and they don't track closed issues - so you should open new issue for As for the solution I hope we'll able test this on next week after moving to .Net Core 2.1. |
@iSazonov: Good idea - please see https://github.com/dotnet/core-setup/issues/4080 |
I'm really not a fan of using a different binary - I think far too many people will use |
We can look at it from the other side based on #3743 and introduce one exe as POSIX-like (or even POSIX-compliant) and second one with traditional behavior. |
It would really be nice to have something for 6.1 that works on Windows as well. I've been trying to use git pre-commit hooks on my Windows dev box to ensure I have the right email configured. This works but it slows down all my commits because it processes my profile scripts when it does not need to:
The only work around I've found is to put the PS script in a separate pre-commit.ps1 file and modify pre-commit to:
But I'd rather there be just a single file. At this point, I'd be satisfied if I could do this:
|
It's obviously just a stopgap, but you can roll your own #!/bin/sh
pwsh -noprofile "$@" Your hooks should then be able to use the shebang you mentioned ( |
Able to Run .ps1 script on zsh manually, however if call same ps1 from ansible playbook gets error that Connect-AzAccount is not recognized. #!/usr/bin/env pwsh is what i use in .ps1 |
@nippyin Please open new issue with step-by-step repo. |
Is I just realized that setting PowerShell as default shell on Linux (using Presence of |
This issue has not had any activity in 6 months, 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. |
1 similar comment
This issue has not had any activity in 6 months, 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. |
This issue has not had any activity in 6 months, 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. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
Steps to reproduce
Put in your PS profile
Create a script
./foo.ps1
andchmod +x
on itFrom bash call
./foo.ps1
Expected behavior
Should not load profile
Reason: that's how bash handles it
Actual behavior
Load profile
Environment data
v0.4.0
The text was updated successfully, but these errors were encountered: