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

Feature request: Allow - (stdin) as input file name #45

Open
pvstodghill opened this issue Jan 19, 2024 · 5 comments
Open

Feature request: Allow - (stdin) as input file name #45

pvstodghill opened this issue Jan 19, 2024 · 5 comments

Comments

@pvstodghill
Copy link

pvstodghill commented Jan 19, 2024

I have a workflow in which I would like to use,

git show tag:foo.md | pandiff - foo.md

However, this hangs. Instead what I end up doing is,

T=$(mktemp)
git show tag:foo.md > $T
pandiff $T foo.md

So the request is that pandiff allow - as an input file without hanging.

Thanks.

@alerque
Copy link

alerque commented Jan 19, 2024

I agree this should work, so +1.

In the mean time you might work around if it doesn't try to seek in the file with filename substitution:

$ pandiff <(git show tag:foo.md) foo.md

If pandiff does try to seek, then this won't work (and that should be fixed too), but it will be a little harder to fix the STDIN issue too ;-)

@pvstodghill
Copy link
Author

Victor, your construction works, which is helpful. Thanks.

@alerque
Copy link

alerque commented Jan 19, 2024

If that also works then it should also be relatively trivial to implement - as an alias for STDIN.

By the way did you try this version?

$ git show tag:foo.md | pandiff /dev/stdin foo.md

@pvstodghill
Copy link
Author

No dice.

$ uname -a
Linux reacted 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ git show tag:foo.md | pandiff /dev/stdin foo.md
[WARNING] Could not deduce format from file extension 
  Defaulting to markdown
pandoc: /dev/stdin: withBinaryFile: does not exist (No such device or address)
Error: 1
$ 

Which is strange because /dev/stdin does exist.

$ vdir /dev/stdin
lrwxrwxrwx 1 root root 15 Jan  9 15:12 /dev/stdin -> /proc/self/fd/0
$ 

and does work,

$ echo foo bar | cat /dev/stdin
foo bar
$ 

@alerque
Copy link

alerque commented Jan 19, 2024

It does exist but it's a different inode type than the process redirection (<(command)) method, so that's not completely surprising.

In any case it shouldn't be too hard to fix properly so it can handle STDIN (aliased as - or otherwise).

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