pipe-rename icon indicating copy to clipboard operation
pipe-rename copied to clipboard

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

Open CptPotato opened this issue 2 years ago • 5 comments

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 :+1:

CptPotato avatar Feb 18 '23 11:02 CptPotato

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.

mtimkovich avatar Feb 23 '23 04:02 mtimkovich

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

CptPotato avatar Feb 25 '23 09:02 CptPotato

@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).

assarbad avatar Feb 26 '23 21:02 assarbad

@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 avatar Feb 27 '23 07:02 CptPotato

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 :confused:. 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: https://github.com/marcusbuffett/pipe-rename/compare/master...CptPotato:pipe-rename:glob

CptPotato avatar May 28 '23 07:05 CptPotato