dash handling of -nt different from bash when one of the targets is missing
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dash (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: dash
The script
rm -f file1 file2
touch file1
if [ file1 -nt file2 ] ; then echo file1 is newer ; else echo file2 is newer ; fi
produces different results when run under bash, dash and explicitly using /usr/bin/test (as opposed to the shell's built in [ implementation)
Bash and test agree that file1 is newer in this case. dash says file2 is newer, which in a way is also "correct" since it has yet to be created? Alas, zsh and ksh from /etc/alternatives on hardy side with dash. The bash documentation at least explicitly states what the outcome is supposed to be in that case, so there are probably shell scripts and (in my case) makefiles that are written to that specification that break with the switch to dash.
lsb_release says:
Description: Ubuntu 8.04.1
Release: 8.04