aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2019-09-25 16:02:21 +0300
committerDylan Araps <dylan.araps@gmail.com>2019-09-25 16:02:21 +0300
commit4157b94228fcdea62c9c6362de582019392dfcee (patch)
treed040c2958dadb002e2320c048de94b209d8c13c0
parentf4e9f3b4cae78cebdc076ddb9b55e07162e709d8 (diff)
downloadpfetch-4157b94228fcdea62c9c6362de582019392dfcee.tar.gz
host: fix sysctl adding newlines to output
-rwxr-xr-xpfetch13
1 files changed, 12 insertions, 1 deletions
diff --git a/pfetch b/pfetch
index 8fbfd74..06b9755 100755
--- a/pfetch
+++ b/pfetch
@@ -217,7 +217,18 @@ get_host() {
;;
*BSD*)
- host=$(sysctl -n hw.vendor hw.product)
+ # Use 'set --' to store the output of the command
+ # as it normalizes whitespace and strips newlines.
+ #
+ # Disable the shellcheck warning for word-splitting
+ # as it's safe and intended ('set -f' disables globbing).
+ # shellcheck disable=2046
+ {
+ set -f
+ set +f -- $(sysctl -n hw.vendor hw.product)
+ }
+
+ host=$*
;;
esac