Web lists-archives.com

Re: bash usage.

On Wed, Oct 25, 2017 at 05:39:35PM -0700, peter@xxxxxxxxxxx wrote:
> According to 'man mountpoint', it returns 0 if something is mounted.  
> So why the complaint from 
>   if [ mountpoint $WorkingDirectory ] ?

The return status is seen by the shell as a numeric.  It is not coerced
to a boolean (like Perl or Python would do).  Try this instead:

# Demonstrate use of "mountpoint" in a script to determine
# whether a directory has a device mounted on it.
mountpoint -q $WorkingDirectory
if [[ $? = 0 ]]
    echo A volume is mounted on $WorkingDirectory.
    echo Nothing mounted on $WorkingDirectory.

Roberto C. Sánchez