Skip to content
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

FZF_DEFAULT_COMMAND breaks when SHELL set to pwsh #3296

Open
6 of 11 tasks
mattcargile opened this issue May 15, 2023 · 4 comments
Open
6 of 11 tasks

FZF_DEFAULT_COMMAND breaks when SHELL set to pwsh #3296

mattcargile opened this issue May 15, 2023 · 4 comments

Comments

@mattcargile
Copy link

mattcargile commented May 15, 2023

  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish
    • pwsh

Problem / Steps to reproduce

When $env:SHELL or $SHELL is set to pwsh -NoLogo on Windows or /usr/bin/pwsh on *nix ( in my case it is RHEL 9 ), usage like

$env:FZF_DEFAULT_COMMAND = 'fd.exe'
fzf

fails with command failed.

I have even tried

$env:SHELL = 'pwsh -NoLogo -NoProfile -ExecutionPolicy Bypass -NonInteractive -InputFormat Text -OutputFormat Text -Command'

on Windows and it still fails.

Workaround

On Windows set $env:SHELL = 'cmd.exe'. On *nix running pwsh, do $env:SHELL = '/usr/bin/bash' or the like.

Workaround Update

On pwsh version 7.3.8, setting $env:SHELL = 'pwsh' does work now. It seems adding parameters will break fzf usage on Windows.

@RH-TLagrone
Copy link

@mattcargile I am encountering the same issue. Have you been able to diagnose the underlying mechanism(s)? If not, could you share any promising leads that you think I could build on to troubleshoot myself?

@mattcargile
Copy link
Author

mattcargile commented Oct 17, 2023

@mattcargile I am encountering the same issue. Have you been able to diagnose the underlying mechanism(s)? If not, could you share any promising leads that you think I could build on to troubleshoot myself?

I'm not sure how to debug it unless you understand the fzf source and how it uses that environment variable.

On pwsh version 7.3.8, I did just try setting $env:SHELL = 'pwsh' and it does work. Adding the parameters is what breaks it. Maybe try it without parameters?

@RH-TLagrone
Copy link

Ah, that explanation seems likely. I've run into issues with Windows treating things like that as a command name (i.e. just the resolvable name of an executable) rather than a command invocation/expression (i.e. to be parsed into a command to execute and arguments to pass to it).

Does fzf have any mechanism to specify a default command for shell invocations that fzf will take care of parsing/interpreting itself? (analogous to the currently-supported environment variables FZF_DEFAULT_COMMAND, FZF_CTRL_T_COMMAND, etc.)

@mattcargile
Copy link
Author

mattcargile commented Oct 23, 2023

Ah, that explanation seems likely. I've run into issues with Windows treating things like that as a command name (i.e. just the resolvable name of an executable) rather than a command invocation/expression (i.e. to be parsed into a command to execute and arguments to pass to it).

Does fzf have any mechanism to specify a default command for shell invocations that fzf will take care of parsing/interpreting itself? (analogous to the currently-supported environment variables FZF_DEFAULT_COMMAND, FZF_CTRL_T_COMMAND, etc.)

I looked briefly at the README.md and didn't see anything. I might try creating a bat or cmd file as your $env:SHELL to get the features you want?

Additionally, after looking at source, if you have pwsh or powershell in your $env:SHELL the command executed is altered and -NoProfile -Command is added. It doesn't appear like fzf is designed for this particular use case. No matter what, on Windows, at least -c added to your $Env:SHELL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants