I understand that mountpoint is used to determine if a given directory is a mountpoint or not. However, what I don't understand is its combination of it and the if statement.
I tested a code snippet from the Internet:
#!/bin/bash if mountpoint -q $1; then echo "$1 is mounted" else echo "$1 isn't mounted" fi
It works! But I am not sure how it works (especially -q means to be quiet). I tried to put the condition into a pair of double square brackets:
if [[ mountpoint -q $1 ]]; then ...
And it doesn't work. So I want to ask what the internal mechanism is that makes this if statement work?