Can I use the
case statement to handle arguments? So, using -restart I'd like execute "-umount" and "-mount"
#!/bin/bash case "$1" in -mount mount /ip/share1 /local/share1 ;; -umount umount /ip/share1 ;; -restart # echo TODO ;; *) [...] esac
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
It looks to me like that should work, other than the syntactical quibble of missing
)s. I tested this and it behaves correctly..
#/bin/bash case "$1" in "-mount") mount /path/to/device /path/to/mountpoint ;; "-unmount") umount /path/to/mountpoint ;; "-mount") "$0" -unmount "$0" -remount ;; *) echo "You have failed to specify what to do correctly." exit 1 ;; esac