Re: bash usage.
- Date: Wed, 25 Oct 2017 21:23:14 -0400
- From: Roberto C. Sánchez <roberto@xxxxxxxxxx>
- Subject: 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