Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when output of lvs has '<' in output, regular expression does not account for lead character #264

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion functions/size_to_bytes.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function lvm::size_to_bytes (
'E' => 1.1529215e18,
}
# Check if the size is valid and if so, extract the units
if $size =~ /^([0-9]+(\.[0-9]+)?)([KMGTPEkmgtpe])/ {
if $size =~ /^<?([0-9]+(\.[0-9]+)?)([KMGTPEkmgtpe])/ {
$unit = String($3, '%u') # Store the units in uppercase
$number = Float($1) # Store the number as a float

Expand All @@ -20,3 +20,4 @@ function lvm::size_to_bytes (
fail("${size} is not a valid LVM size")
}
}