bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Collin Funk
Subject: bug#79232: tsort doesn't support -w added by POSIX 2024.
Date: Wed, 13 Aug 2025 23:14:12 -0700
User-agent: Gnus/5.13 (Gnus v5.13)

Collin Funk <collin.funk1@gmail.com> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]