Severity 373611 wishlist
Retitle 373611 Please update manpage to show "test" built-in behaviour.
Tags 373242 + pending
Thanks

Gerrit Pape wrote on 14/06/2006 17:11:
> On Wed, Jun 14, 2006 at 04:09:40PM +0200, Sven Mueller wrote:
> 
>>Gerrit: Please see below for a summary of why I think this is a "dash"
>>bug. I clone the bug instead of just reassigning it because I will
>>implement a workaround in my package and will close the bug in the
>>changelog accordingly.
>>
>>I'm sorry, but the test syntax is absolutely OK for a Debian system (see
>>"man test") and it certainly is no "bashism". The problem is that dash
>>wants to override the normal "test" binary but doesn't allow it's full
>>syntax. Dash is the only shell I know of that doesn't allow use of the
>>"-nt" (newer than) test.
> 
> Hi Sven, dash supports the -nt and -ot options to the test builtin, see
> also dash(1):
> 
>  $ dash -ec 'touch foo; sleep 1; touch bar; test foo -nt bar; echo $?'
>  1
>  $ dash -ec 'touch foo; sleep 1; touch bar; test foo -ot bar; echo $?'
>  0
>  $ 

Ah, thanks, that gives me a further hint at what's happening here. I
must have been a bit blind when I read the log.

It seems that both the "bash" built-in "test" as well as /usr/bin/test
report success on "test A -nt B" when B doesn't exist while dash reports
a failure.

(in the debian subdir of the nslint source, so control exists,
changelog1 doesn't)

bash$ /usr/bin/test control -nt changelog1 && echo YES || echo NO
bash$ test control -nt changelog1 && echo YES || echo NO
YES
YES
dash$ test control -nt changelog1 && echo YES || echo NO
NO

Hmm, this is actually undocumented behaviour it seems.
man bash says on this:
       file1 -nt file2
              True if file1 is newer (according to modification date)
              than file2, or if file1 exists and file2 does not.
man dash says on this:
            file1 -nt file2
              True if file1 exists and is newer than file2.
man test says:
       FILE1 -nt FILE2
              FILE1 is newer (modification date) than FILE2

So only bash is specific about the behaviour. Hmm, Perhaps this should
be documented more cleanly. Probably the entry for dash should read:
"True if both file1 and file2 exist and file1 is newer than file2"
Or the dash implementation should be changed to work the same way the
standalone works. Note: I also test -ot, but for that, the behaviour of
/usr/bin/test, the bash built-in and the dash built-in seem to match
(report false if either file is missing).

> I think the problem in #373611 is that /usr/share/misc/config.guess does
> not exist, and the cp program barfs.

Yes, but it barfs for a completely different reason than I would have
expected. I could implement a small shell function which does those
tests in the way /usr/bin/test would do them, but I suppose just calling
 /usr/bin/test explicitly is easier, so I will stick with that for now.

Regards,
Sven


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to