vim:funcs:crypt-*mount: Split local declarations
Split up local declarations into definition and declaration to get the exit code of the command substitution. With `err_return` the function now aborts early if `$mount_point` couldn't be set properly.
This commit is contained in:
@@ -257,10 +257,13 @@ crypt-mount() {
|
|||||||
[[ $# -gt 0 ]]
|
[[ $# -gt 0 ]]
|
||||||
[[ -b "$1" ]]
|
[[ -b "$1" ]]
|
||||||
|
|
||||||
local name=crypt_"${1##*/}"
|
local name mount_point
|
||||||
|
name=crypt_"${1##*/}"
|
||||||
|
|
||||||
sudo cryptsetup open "$1" "$name"
|
sudo cryptsetup open "$1" "$name"
|
||||||
udisksctl mount -b /dev/mapper/"$name"
|
udisksctl mount -b /dev/mapper/"$name"
|
||||||
local mount_point="$(
|
|
||||||
|
mount_point="$(
|
||||||
findmnt -lo SOURCE,TARGET \
|
findmnt -lo SOURCE,TARGET \
|
||||||
| grep -F /dev/mapper/"$name" \
|
| grep -F /dev/mapper/"$name" \
|
||||||
| awk '{ print $2; }'
|
| awk '{ print $2; }'
|
||||||
@@ -281,7 +284,8 @@ crypt-umount() {
|
|||||||
|
|
||||||
sync
|
sync
|
||||||
|
|
||||||
local name=crypt_"${1##*/}"
|
local name mount_point
|
||||||
|
name=crypt_"${1##*/}"
|
||||||
|
|
||||||
if
|
if
|
||||||
mount | grep -q /dev/mapper/"$name" \
|
mount | grep -q /dev/mapper/"$name" \
|
||||||
@@ -296,7 +300,7 @@ crypt-umount() {
|
|||||||
fi
|
fi
|
||||||
udisksctl power-off -b "$1"
|
udisksctl power-off -b "$1"
|
||||||
|
|
||||||
local mount_point="$(
|
mount_point="$(
|
||||||
findmnt -lo SOURCE,TARGET \
|
findmnt -lo SOURCE,TARGET \
|
||||||
| grep -F /dev/mapper/"$name" \
|
| grep -F /dev/mapper/"$name" \
|
||||||
| awk '{ print $2; }'
|
| awk '{ print $2; }'
|
||||||
|
|||||||
Reference in New Issue
Block a user