aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2018-09-29 11:07:28 +0200
committerDavid Runge <dave@sleepmap.de>2018-09-29 11:07:28 +0200
commit56848bd7e34f484cdce7a69258cf22a57108d231 (patch)
tree04c7598d1b56a524a598adf9da0ba377d2565b67 /bin
parent9f979a5612d81d9bf6ef4b1978a6a53666895ce3 (diff)
downloaddotfiles-56848bd7e34f484cdce7a69258cf22a57108d231.tar.gz
dotfiles-56848bd7e34f484cdce7a69258cf22a57108d231.tar.bz2
dotfiles-56848bd7e34f484cdce7a69258cf22a57108d231.tar.xz
dotfiles-56848bd7e34f484cdce7a69258cf22a57108d231.zip
bin/cs: Fixing script according to shellcheck.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cs26
1 files changed, 13 insertions, 13 deletions
diff --git a/bin/cs b/bin/cs
index 363ba12..4eb7fe6 100755
--- a/bin/cs
+++ b/bin/cs
@@ -19,7 +19,7 @@ function open_cryptdevice() {
echo "Crypt device has already been opened: /dev/mapper/$2"
echo "Continuing..."
else
- /usr/bin/sudo /usr/bin/cryptsetup luksOpen "/dev/disk/by-uuid/$1" $2
+ /usr/bin/sudo /usr/bin/cryptsetup luksOpen "/dev/disk/by-uuid/$1" "$2"
fi
else
echo "Error: Device $2 (UUID=$1) is not available."
@@ -28,7 +28,7 @@ function open_cryptdevice() {
}
function close_cryptdevice() {
- /usr/bin/sudo /usr/bin/cryptsetup luksClose $1
+ /usr/bin/sudo /usr/bin/cryptsetup luksClose "$1"
}
function mount_cryptdevice() {
@@ -50,35 +50,35 @@ function unmount_cryptdevice() {
if [ -x "$HOME/.config/cs/pre_umount/$1" ]; then
"$HOME/.config/cs/pre_umount/$1"
fi
- /usr/bin/sudo /usr/bin/umount /mnt/$1
+ /usr/bin/sudo /usr/bin/umount "/mnt/$1"
}
function validate_cryptdevice_name() {
- local _result_valid_name=$1
+ local _result_valid_name="$1"
local name_found=0
- local input_name=${2:-}
+ local input_name="${2:-}"
for name in "${!devices[@]}"; do
- if [ $name = "${input_name}" ]; then
+ if [ "$name" = "${input_name}" ]; then
name_found=1
- eval $_result_valid_name="'$name_found'"
+ eval "$_result_valid_name"="$name_found"
fi
done
}
-validate_cryptdevice_name valid_name ${device_name}
+validate_cryptdevice_name valid_name "${device_name}"
if [ $valid_name -eq 0 ]; then
echo "No such device: '$device_name'!"
exit 1
fi
-case $1 in
+case "$command_name" in
"open")
- open_cryptdevice ${devices[${2}]} $2
- mount_cryptdevice $2
+ open_cryptdevice "${devices[${2}]}" "$2"
+ mount_cryptdevice "$2"
;;
"close")
- unmount_cryptdevice $2
- close_cryptdevice $2
+ unmount_cryptdevice "$2"
+ close_cryptdevice "$2"
;;
*)
echo "cs only understands 'open' and 'close'."