On 08/08/2012 06:07 PM, Jim Meyering wrote:
> Bernhard Voelker wrote:
> 
>> On 08/08/2012 05:43 PM, Pádraig Brady wrote:
>>
>>> +require_mount_list_()
>>> +{
>>> +  df >/dev/null 2>&1 ||
>>> +    skip_ "Unable to read the list of mounted file systems."
>>> +}
>>> +
>>
>> Hmm, I think this is not enough: df can also fail due to other reasons,
>> e.g. when a mount point is not reachable by the user:
>>
>>   $ src/df > /dev/null  ; echo $?
>>   src/df: ‘/root/backup’: Permission denied
>>   1
> 
> Good point.
> 
> "df ." or "df /" should be more reliable.

Good idea, but doesn't work either:

  $ src/df . ; echo $?
  src/df: Warning: cannot read table of mounted file systems: No such file or 
directory
  Filesystem     1K-blocks      Used Available Use% Mounted on
  -              354786776 259885664  93819788  74% /media/sdb5
  0

It's because that's only a warning when arguments are given:

       /* Couldn't read the table of mounted file systems.
         Fail if df was invoked with no file name arguments;
         Otherwise, merely give a warning and proceed.  */

Have a nice day,
Berny

Reply via email to