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

Can't pipe file names to pipe-rename without -y #65

Open
CptPotato opened this issue Feb 18, 2023 · 5 comments
Open

Can't pipe file names to pipe-rename without -y #65

CptPotato opened this issue Feb 18, 2023 · 5 comments

Comments

@CptPotato
Copy link

I've ran into an issue when piping file names into rename. The editor opens correctly, but after closing it the program immediately exits at the prompt:

Execute these renames?:
> Yes
  No
  Edit
  Reset
Error: Incorrect function. (os error 1)
error: process didn't exit successfully: `target\debug\renamer.exe` (exit code: 1)

Running in debug mode didn't provide a stack trace but it looks like it's the call to dialoguer::prompts::select::Select. Using -y to skip the prompt works as an alternative. I'm using Windows if that makes a difference.

Also, thanks for this cool tool 👍

@mtimkovich
Copy link
Collaborator

mtimkovich commented Feb 23, 2023

Thanks for the report! It seems Windows-specific due to the Incorrect function error. What shell are you using? I'm worried this might be a dialoguer bug.

@assarbad have you been encountering this problem?

Edit: Seems like dialoguer doesn't work with Cygwin or GitBash. It does work with cmd.exe and Powershell however.

@CptPotato
Copy link
Author

Yes, this might be a dialoguer issue.

What shell are you using?

I'm using regular Cmd. Powershell has the same behavior, Git bash (launched from Cmd or using mingw64) is no different.

For now I've worked around the issue by patching in glob support. I mostly used something like this fd -g **/*.exr | renamer which I can do without piping now (renamer **/*.exr).

@assarbad
Copy link
Contributor

assarbad commented Feb 26, 2023

@mtimkovich I have not, but I am trying to avoid using it in piped mode. I think the issue, albeit on Windows, is the same as we have seen on other platforms.

I have been investigating reopening /dev/tty from within renamer, but that's also a Unix-only solution to the best of my understanding.

@CptPotato feel like sharing (or contributing by way of a PR) the patch? Basic globbing support is included now on Windows, but indeed the full breadth of what various shells provide may not be covered by it (such as **/*.exr).

@CptPotato
Copy link
Author

@CptPotato feel like sharing (or contributing by way of a PR) the patch? Basic globbing support is included now on Windows, but indeed the full breadth of what various shells provide may not be covered by it (such as **/*.exr).

Sure! I'll have to clean it up a little but I can create a PR soon.

@CptPotato
Copy link
Author

CptPotato commented May 28, 2023

Sorry this went way under the radar for me. I can't seem to reproduce the issue I had with **/*.exr on my new machine 😕. It looks like the pattern is correctly expanded by the shell or something since opts.files already contains all the paths now.

Either way, in case you're interested here's the diff: master...CptPotato:pipe-rename:glob

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

3 participants