+1 to what slavic and ofnuts said. Slavik's adivice was well-minded, but it might be misleading if you don't have package manpages-posix installed. The manual page he meant is exec(1posix). Since exec is impemented as bash builtin, you may also want to look it up in the bash info manual, or in the ABS.
Concerning your code, I'd probably rewrite this
Code:
AUTORUN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
as
Code:
AUTORUN_DIR=$(readlink -f "$0")
Strictly speaking, even this is not needed as df is able to walk through symlinks, so should be enough.
BTW, better not name your script variables in all-caps as it may interfere with environment variables.
Also, if the only purpose of finding the mount point is to check whether it's a removable media then better approach would be directly evaluating device name:
Code:
device=$(df "$0"|awk 'NR>1{print $1}')
removable=$(lsblk -r -n -o RM $device)
if ((removable))
then echo Running off of removable media
else echo Running off of fixed drive
fi
Just for fun, doing the above snippet in one pass:
Code:
((`lsblk -rnorm $(df "$0"|sed '1d;s/ .*//')`))&&media_type=removable||media_type=fixed
echo Running off of $media_type media
Bookmarks