From: <Joe...@t-...> - 2017-03-20 13:59:51
|
Hi, > newer(){ echo 'test -f $$m/'$1' -a $$m/'$1' -nt $@/'$2; } >I've now replaced this use of an unportable shell primitive with a small auxiliary program. Recently I saw a use of 'find' to compare dates of 2 files! Alas, I have no idea how portable find's -maxdepth 0 option is $ find foo -maxdepth 0 -newer bar -ls So maybe an old-fashioned prune is the better option? $ find foo -prune -newer bar -ls Linux and OSX document maxdepth. However, the section on standards conformance in a Linux manpage mentions -prune, not -maxdepth. This HP-UX manpage does not document -maxdepth http://nixdoc.net/man-pages/HP-UX/find.1.html Is there really a need to add 1000 lines of code to the repository and several new tests and gnulib modules *just for the utilities*, not even the actual program, just to compare dates? Here's what looks like logic that should work across 40 years of UNIXisms newer(){ [ -f "$1" ] && ([ ! -e "$2" ] || test -n "`find "$1" -prune -newer "$2"`"); } Regards, Jörg |