Web lists-archives.com

Re: bash usage.




On 26 October 2017 at 11:39,  <peter@xxxxxxxxxxx> wrote:
>
> According to 'man mountpoint', it returns 0 if something is mounted.
> So why the complaint from
>   if [ mountpoint $WorkingDirectory ] ?

Answered here:

http://mywiki.wooledge.org/BashPitfalls#if_.5Bgrep_foo_myfile.5D

http://mywiki.wooledge.org/BashGuide/TestsAndConditionals#Conditional_Blocks_.28if.2C_test_and_.5B.5B.29

On 26 October 2017 at 12:23, Roberto C. Sánchez <roberto@xxxxxxxxxx> wrote:
>
> mountpoint -q $WorkingDirectory
> if [[ $? = 0 ]]

That will work, but is ridiculous considering this works by design:

if mountpoint -q "$wd" ; then
  echo "$wd is a mountpoint"
fi