Skip to content

Instantly share code, notes, and snippets.

@kaizoku
Last active July 8, 2019 23:05
Show Gist options
  • Save kaizoku/593386 to your computer and use it in GitHub Desktop.
Save kaizoku/593386 to your computer and use it in GitHub Desktop.
mount(8) wrapper which creates the target directory if it doesn't exist
#!/bin/bash
# wrapper for mount which mkdirs the mount target if it doesn't exist
device="${@: -2}"
mntdir="${@: -1}"
if [ "$device" -o "${device:0:1}" == "-" ]
then
:
elif [ "${mntdir:0:1}" == "-" ]
then
:
elif [ -d "$mntdir" ]
then
:
else
mkdir "$mntdir"
fi
mount ${@}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment