pandiff icon indicating copy to clipboard operation
pandiff copied to clipboard

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

Open pvstodghill opened this issue 2 years ago • 5 comments

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.

pvstodghill avatar Jan 19 '24 18:01 pvstodghill

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

alerque avatar Jan 19 '24 20:01 alerque

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

pvstodghill avatar Jan 19 '24 20:01 pvstodghill

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

alerque avatar Jan 19 '24 20:01 alerque

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
$ 

pvstodghill avatar Jan 19 '24 21:01 pvstodghill

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

alerque avatar Jan 19 '24 21:01 alerque