I'm running RHEL 7 and bash here. It seems command substitution does not work for the umount command. It does, however, work as usual for other commands. For example:
[[email protected] ~]# msg=$(umount /u01) umount: /u01: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1)) [[email protected] ~]# echo "$msg" - nothing here - [[email protected] ~]# msg=$(mountpoint /u01) [[email protected] ~]# echo "$msg" /u01 is a mountpoint
What I can probably do is to use mountpoint first and then umount if the mountpoint exists. Then check for umount status - if there is an error I guess the device must be busy.