Il 06/09/2012 14:30, Pádraig Brady ha scritto: >> >> I consider "shuf foo -o foo" (on a read-write file) to be insecure. >> Besides, it works by chance just because it reads everything in memory >> first. If it used mmap to process the input file, "shuf foo -o foo" >> would be broken, and the only way to fix it would be to do the same as >> "sed -i". >> >> shuf could in fact introduce a "shuf -i" mode that would be consistent >> with the way "sed -i" works, including the ability to create a backup >> file _and_ the breaking of hard links. > > Well `sort` and `shuf` need to read all their input before > generating output.
Yes, but they could use mmap instead of a single large buffer to cope with files that are bigger than the available memory, but smaller than the address space. > This is traditional behavior and > POSIX also states that -o can refer to one of the input files. Interesting, thanks! Paolo