From f8644f03d0307f2d6bea2db9c1efacad89e9ea99 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 12 Dec 2017 23:45:00 +0000 Subject: [PATCH] etc/profile.d/nb.sh --- etc/profile.d/nb.sh | 8 ++++---- etc/profile.d/sys.sh | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/etc/profile.d/nb.sh b/etc/profile.d/nb.sh index 4dd598c9..9e0d89a4 100644 --- a/etc/profile.d/nb.sh +++ b/etc/profile.d/nb.sh @@ -91,9 +91,9 @@ nb_api_post() { } nb_post_sys_infos() { -( - sys_infos | while IFS=$'\t' read -r key val; do - nb_api_post host_info "key=$key" "val=$val" + ( + sys_infos | sed -e 's/"/\\"/g' -e 's/^/key="sys./' -e 's/\t/" val="/' -e 's/$/"/' | while read -r i; do + eval nb_api_post host_info $i done -) | sed 's/^/nb_post_sys_infos: /' + ) } diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index c24908be..99329434 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -4,12 +4,11 @@ # NB 10.12.16 esac sys_infos() { - local n='>/dev/null 2>&1' - local s=$'\t' + local s="$(printf '\t')" cat </dev/null ) nproc${s}$( (nproc || sysctl -n hw.ncpu || grep ^proc /proc/cpuinfo | wc -l) 2>/dev/null ) -date_install $( (date -r $(ls -1drt /lost+found /etc/ssh/ssh_host_dsa_key.pub /etc/ssh_host_dsa_key.pub|head -1) +'%F %T') 2>/dev/null ) +date_install${s}$( (date -r $(ls -1drt /lost+found /etc/ssh/ssh_host_dsa_key.pub /etc/ssh_host_dsa_key.pub|head -1) +'%F %T') 2>/dev/null ) EOF } -- 2.47.3