Re: bash usage.
- Date: Thu, 26 Oct 2017 06:59:51 -0400
- From: Roberto C. Sánchez <roberto@xxxxxxxxxx>
- Subject: Re: bash usage.
On Thu, Oct 26, 2017 at 04:19:42PM +1100, David Margerison wrote:
> 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:
> 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"
Yes, quite right. Though, my syntax makes it clear that what is being
tested/evlauated is the exit status, not the output. I know that the if
evaluates the exit status, but that may not be immediately evident to
someone who is not particularly familiar with shell programming.
To each his own.
Roberto C. Sánchez