Hi Gunter,

Gunter Schmidt via bug-diffutils via "All diffutils discussion."
<[email protected]> writes:

> I noticed, the utility name in error messages is not sdiff for sdiff.
>
> Example with missing files:
>
> $> *s*diff foo bar
> diff: foo: No such file or directory
> diff: bar: No such file or directory
>
> *Error: Returns wrong util name.
> Expectation: sdiff*

This is the expected behavior.

The 'sdiff' program just invokes 'diff' in this case.

    $ PATH=/usr/bin strace -e trace='/(exec|clone|v?fork)' sdiff foo bar
    execve("/usr/bin/sdiff", ["sdiff", "foo", "bar"], 0x7ffd9303bb20 /* 89 vars 
*/) = 0
    execve("/usr/bin/diff", ["diff", "-y", "--", "foo", "bar"], 0x7ffe1a493a18 
/* 89 vars */) = 0
    diff: foo: No such file or directory
    diff: bar: No such file or directory
    +++ exited with 2 +++


The 'diff' program fails after it cannot open those files

    $ PATH=/usr/bin strace -e trace='/open' sdiff foo bar 2>&1 | grep -F ENOENT
    openat(AT_FDCWD, "foo", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
directory)
    openat(AT_FDCWD, "bar", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
directory)

> This gets even more odd, when comparing
>
> $> mydir/diff foo bar
> mydir/diff: foo: No such file or directory
> mydir/diff: bar: No such file or directory
>
> $> mydir/sdiff foo bar
> diff: foo: No such file or directory
> diff: bar: No such file or directory
> no path and wrong tool name

This is because 'sdiff' is invoking 'diff' from your $PATH.

This should make it a bit more clear:

    $ ./src/sdiff --diff-program=./src/diff foo bar
    ./src/diff: foo: No such file or directory
    ./src/diff: bar: No such file or directory

> Personally I do not think the mydir/ should be part of the error
> message, but that reasoning is not up to me.

Likewise. It is because diffutils does not use the error function from
Gnulib. That will print the basename of argv[0].

Collin



Reply via email to