On 02/19/2018 06:53 AM, Yuriy Vostrikov wrote:
Hello, Is this expected behavior? $ cd /tmp $ mkdir foo $ cd foo/ $ touch a $ /usr/bin/test a -nt b; echo $? 0 $ /bin/bash -c 'test a -nt b; echo $?' 0 $ /bin/dash -c 'test a -nt b; echo $?' 1
Yes. -nt is not specified by POSIX, and the behavior of -nt when one of the two operands does not exist can make sense under multiple interpretations (treat a missing file as a silent error, where both 'a -nt b' and 'b -nt a' fail with status 1 [dash]; treat a missing file as always newer, because once you make it exist it will have a newer timestamp [not sure if anyone does that]; treat a missing file as a hard error with message to stderr and status 2 [not sure if anyone does that]; treat a missing file as always older, perhaps because you use the default timestamp of Jan 1 1970 when interpreting all 0's for any file that fails to stat [bash, coreutils]). The same problem of multiple interpretations also applies to -ot.
At any rate, I don't see it as a bug in dash, so much as your script making non-portable assumptions about non-standardized behavior.
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html