bug#79232: tsort doesn't support -w added by POSIX 2024.

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
Collin Funk <[email protected]> writes:

> However, that means that when POSIXLY_CORRECT is not defined the exit
> status is ambiguous as shown in the following example:
>
>     # Input with a cycle.
>     $ printf 'a b\nb a\n' | ./src/tsort
>     tsort: -: input contains a loop:
>     tsort: a
>     tsort: b
>     a
>     b
>     $ echo $?
>     1
>     # Program error.
>     $ echo 'a a' | ./src/tsort > /dev/full
>     tsort: write error: No space left on device
>     $ echo $?
>     1

Oops, slight mistake in that example. Pretend that './src/tail' was
given the -w argument. The output and exit status will be the same.

Here it is run with POSIXLY_CORRECT set:

    $ printf 'a b\nb a\n' | POSIXLY_CORRECT=1 ./src/tsort -w
    tsort: -: input contains a loop:
    tsort: a
    tsort: b
    a
    b
    $ echo $?
    1
    $ echo 'a a' | POSIXLY_CORRECT=1 ./src/tsort > /dev/full
    tsort: write error: No space left on device
    $ echo $?
    125

We can use the exit value to determine the number of cycles (0 - 124) or
an error (125) in this case.

Collin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.