Skip to content

Commit

Permalink
Add forced locale to parted command, change drive name parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtpep committed Dec 17, 2014
1 parent 9adb5bd commit 88c7a15
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ run-script() {
}

parse-drive-name() {
grep "^Model: \|^Disk /" | sed "/^Model: .*/N;s|^Model: \(.*\) (.*)\nDisk \(/.*\): \(.*\)|\1 (\3) \2|"
grep -A 1 "^Model:" | sed "N; s|^Model: \(.*\) (.*)\nDisk \(/.*\): \(.*\)|\1 (\3) \2|"
}

mounted-drive-path() {
Expand All @@ -82,8 +82,9 @@ select-drive() {
return
fi

local parted_output=`sudo LC_ALL=POSIX parted -ls 2>&1`
local host_drive_path=`mounted-drive-path /`
local options=(`sudo parted -ls | parse-drive-name | grep -v ") $host_drive_path$"`)
local options=(`echo "$parted_output" | parse-drive-name | grep -v ") $host_drive_path$"`)
if [[ -z ${options:-} ]]; then
[[ -z ${is_quiet:-} ]] || return 0
fatal-error "No drives were found."
Expand All @@ -109,7 +110,7 @@ select-drive() {
}

detect-drive-name() {
drive_name=`sudo parted -s $drive_path print 2>/dev/null | parse-drive-name`
drive_name=`sudo LC_ALL=POSIX parted -s $drive_path print 2>/dev/null | parse-drive-name`
}

partition-path() {
Expand Down

0 comments on commit 88c7a15

Please sign in to comment.