Giter Site home page Giter Site logo

Comments (11)

dandavison avatar dandavison commented on May 18, 2024

Hi @calestyo, I thought that it worked like that already! Can you post an example? This is MacOS in zsh.

~ delta <(echo a) <(echo a) > /dev/null; echo $?
0
~ delta <(echo a) <(echo b) > /dev/null; echo $?
1
~ delta <(echo a) __not_there__ > /dev/null; echo $?
diff: __not_there__: No such file or directory
2

from delta.

calestyo avatar calestyo commented on May 18, 2024

Indeed. Not sure how I produced the contradicting result.... I've been calling delta from a shell script, and I think there might have been an exit 1 at a wrong point, which has overridden delta’s 2.

Sorry for the noise.

btw: Is there a way in delta to disable colour output?

from delta.

dandavison avatar dandavison commented on May 18, 2024

No worries.

btw: Is there a way in delta to disable colour output?

You mean, keep all the reformatting and decorations but specifically disable colour? I don't think there is a way to do that, although perhaps there are enough colour settings in delta to achieve it piecemeal!

So in a script the answer would be not to call delta if one only wants the raw git/diff input, and of course, git doesn't invoke delta at all if output is not a tty. But if you explicitly pipe to delta in a script then it will add colours and text decorations / reformatting.

from delta.

calestyo avatar calestyo commented on May 18, 2024

No worries.

I reproduced it... wait a second...

from delta.

calestyo avatar calestyo commented on May 18, 2024
$ touch foo
$ stat /tmp/bar
stat: cannot statx '/tmp/bar': No such file or directory
$ delta foo /tmp/bar ; echo $?
error: Could not access '/tmp/bar'
1

If I do however:

$ delta <(echo foo) /tmp/bar ; echo $?
diff: /tmp/bar: No such file or directory
2

from delta.

dandavison avatar dandavison commented on May 18, 2024

Ah-ha, I'm not at my computer but I do remember that the code handling process substitutions had to do something unfortunate. Feel free to investigate!

from delta.

calestyo avatar calestyo commented on May 18, 2024

There are more cases:

$ delta /dev/null non-existent
$ delta /dev/random non-existent
$ delta /dev/uinput non-existent

all give 1, and only uinput is permission-wise not accessible by the user.

Also:

$ ln -s /nonexistent dangling.symlink
$ delta dangling.symlink non-existent

Though it works when comparing with an existent file (not sure, btw. whether it should even then, cause then there's still one inaccessible file - the target of the dangling symlink).

from delta.

calestyo avatar calestyo commented on May 18, 2024

Also when doing using a directory as existent file:

$ delta /tmp non-existent

from delta.

calestyo avatar calestyo commented on May 18, 2024

That issue may even go yet a bit further.

Assume I do:

foo="$(diff -u a b)"

(and there is a difference)

and then:

printf '%s\n' "$foo"  |  delta

I get the differences shown, but exit status is 0 (and not 1).

from delta.

dandavison avatar dandavison commented on May 18, 2024

That's right, in something | delta delta behaves like cat or bat -- it's just a pager displaying stuff and exit code is 0 unless something goes wrong. On the other hand in delta a b delta acts as a diff program, and exit codes are as diff.

from delta.

calestyo avatar calestyo commented on May 18, 2024

Well unless for the other cases mentioned above, where one does have delta a b style and it still doesn't act like diff. :-)

from delta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.