From 49cee215edf34d14b4e69e9e5cde03dde6821458 Mon Sep 17 00:00:00 2001 From: Guo Yunhe Date: Tue, 11 Jun 2019 10:24:59 +0300 Subject: [PATCH] Fix #13 --- CHANGELOG.md | 9 ++++++++- opi | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aa18cd..0bc85ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.5.2] + +### Fixed + +- Trim "NAME" and "VERSION" string [#13](https://github.com/openSUSE-zh/opi/issues/13) + ## [0.5.1] ### Fixed @@ -78,7 +84,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Choose package and install - Keep or remove repository after installation -[Unreleased]: https://github.com/openSUSE-zh/opi/compare/v0.5.1...HEAD +[Unreleased]: https://github.com/openSUSE-zh/opi/compare/v0.5.2...HEAD +[0.5.2]: https://github.com/openSUSE-zh/opi/compare/v0.5.1...v0.5.2 [0.5.1]: https://github.com/openSUSE-zh/opi/compare/v0.5.0...v0.5.1 [0.5.0]: https://github.com/openSUSE-zh/opi/compare/v0.4.0...v0.5.0 [0.4.0]: https://github.com/openSUSE-zh/opi/compare/v0.3.2...v0.4.0 diff --git a/opi b/opi index 21b8bfa..1bc3127 100755 --- a/opi +++ b/opi @@ -117,14 +117,20 @@ Get system information =cut +sub trim { + my $s = shift; + $s =~ s/^\s+|\s+$//g; + return $s +} + sub get_distribution { my $prefix = shift; my $config = Config::Tiny->read('/etc/os-release'); my $name = $config->{_}->{NAME}; my $version = $config->{_}->{VERSION}; - $name = substr $name, 1, -1; # Remove quotes + $name = trim(substr($name, 1, -1)); # Remove quotes and trailing spaces if ($version) { - $version = substr $version, 1, -1; # Remove quotes + $version = trim(substr($version, 1, -1)); # Remove quotes } if ($name eq 'openSUSE Tumbleweed') { $name = 'openSUSE:Factory';