[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
tsort with odd number of items does not give an error.
From: |
junkio |
Subject: |
tsort with odd number of items does not give an error. |
Date: |
23 Apr 2003 03:37:13 -0700 |
$ tsort --version
tsort (coreutils) 4.5.4
Written by Mark Kettenis.
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The Info page describes:
`tsort' reads its input as pairs of strings, separated by
blanks, indicating a partial ordering. The output is a total
ordering that corresponds to the given partial ordering.
I am not quite sure what "as pairs of strings" exactly means
when there are more then two tokens on a line. Does the
following mean "a < b && c < d" (no ordering is specified
between b and c), or "a < b && b < c && c < d"? What the
implementation does implies the former:
$ echo a b c d | tsort
a
c
b
d
However, then what does the following mean?
$ echo a b c | tsort
a
c
b
It is clear from the output this does not mean "a < b && b < c"
to the implementation. But it gets worse.
$ (echo a b c; echo c a) | tsort
a
c
b
The second line explicitly specifies "c < a" but the output does
not honor that. It appears that the only sane interpretation of
the behaviour of the implementation is that the entire output is
undefined when there is a line with an odd number of items in
the input, and no error diagnosis is made. I think it should at
least complain about such an input.
- tsort with odd number of items does not give an error.,
junkio <=