Joerg Wunsch [mailto:aus...@uriah.heep.sax.de] > df -P appears to be required to have the filesystem name as the first > column. Filesystem names with a space however might be a problem, at > least if they contain a number after the space since that cannot be > distinguished from the number of blocks.
It's not just spaces. Filesystem names may contain newlines and other control characters, too, so "df -P" is fundamentally unsafe. If you want to handle filesystem names safely, securely, or correctly, you *cannot* use line-at-a-time processing. In general, handling filenames correctly using only the POSIX standard is full of dangerous "gotchas" and often difficult. The "usual" ways people do it (e.g., line-at-a-time processing) are *wrong*, because the spec doesn't guarantee they're safe and in practice they are definitely NOT safe. Many commonly-used countermeasures, like \0 termination, are not in POSIX at all (see previous discussions). For more information, see: https://www.dwheeler.com/essays/fixing-unix-linux-filenames.html --- David A. Wheeler