aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2012-08-12 01:38:13 +0200
committerTom Gundersen <teg@jklm.no>2012-08-12 01:38:13 +0200
commite37f65b3125e7008b836e13f4aa7d5ecafb0d9c7 (patch)
tree58bf4e8fe13200d2ae7d1c294f87b0c474c04eaf /functions
parent05d0b4ec34bb95ad0e0e139e299e388e689d7c91 (diff)
parente2382e7ed838747052355527c87be6763c581ba2 (diff)
downloadinitscripts-e37f65b3125e7008b836e13f4aa7d5ecafb0d9c7.tar.xz
Merge remote-tracking branch 'falconindy/working'
Diffstat (limited to 'functions')
-rw-r--r--functions19
1 files changed, 14 insertions, 5 deletions
diff --git a/functions b/functions
index e6b9af3..eb08ba6 100644
--- a/functions
+++ b/functions
@@ -72,9 +72,19 @@ unset TZ
# sanitize the locale settings
unset "${localevars[@]}"
+unquote() {
+ local -r quotes=$'[\'"]'
+
+ if [[ ${1:0:1} = $quotes && ${1:(-1)} = "${1:0:1}" ]]; then
+ printf '%s' "${1:1:(-1)}"
+ else
+ printf '%s' "$1"
+ fi
+}
+
parse_envfile() {
local file=$1 validkeys=("${@:2}") ret=0 lineno=0 key= val=
- local -r quotes=$'[\'"]' comments=$'[;#]*'
+ local -r comments=$'[;#]*'
if [[ -z $file ]]; then
printf "error: no environment file specified\n"
@@ -101,8 +111,7 @@ parse_envfile() {
[[ -z $key || ${key:0:1} = $comments ]] && continue
# trim whitespace, strip matching quotes
- val=$(echo "$val" | { read -r val; echo "$val"; })
- [[ ${val:0:1} = $quotes && ${val:(-1)} = "${val:0:1}" ]] && val=${val:1:(-1)}
+ val=$(echo "$val" | { read -r val; unquote "$val"; })
if [[ -z $val ]]; then
printf "error: found key \`%s' without value on line %s of %s\n" \
@@ -478,10 +487,10 @@ do_unlock_systemd() {
# lazily convert tags to udev symlinks
case $device in
UUID=*)
- device=/dev/disk/by-uuid/${device#UUID=}
+ device=/dev/disk/by-uuid/$(unquote "${device#UUID=}")
;;
PARTUUID=*)
- device=/dev/disk/by-partuuid/${device#PARTUUID=}
+ device=/dev/disk/by-partuuid/$(unquote "${device#PARTUUID=}")
;;
esac