diff --git a/info.sh b/info.sh index 9800c88..8172e2a 100644 --- a/info.sh +++ b/info.sh @@ -18,12 +18,12 @@ fi # toiec toiec() { - echo "$(printf "%'d" $(( $1 >> 10 ))) MiB$([[ $1 -ge 1048576 ]] && echo " ($(numfmt --from=iec --to=iec-i "${1}K")B)")" + echo "$(printf "%'d" $(($1 >> 10))) MiB$([[ $1 -ge 1048576 ]] && echo " ($(numfmt --from=iec --to=iec-i "${1}K")B)")" } # tosi tosi() { - echo "$(printf "%'d" $(( (($1 << 10) / 1000) / 1000 ))) MB$([[ $1 -ge 1000000 ]] && echo " ($(numfmt --from=iec --to=si "${1}K")B)")" + echo "$(printf "%'d" $(((($1 << 10) / 1000) / 1000))) MB$([[ $1 -ge 1000000 ]] && echo " ($(numfmt --from=iec --to=si "${1}K")B)")" } . /etc/os-release @@ -34,7 +34,7 @@ KERNEL=$(> 10 ))) KiB × ${CPU_NUM_CACHES[$cache]} ($(numfmt --to=iec-i "${CPU_TOTAL_CACHE_SIZES[$cache]}")B)" + ((i)) && printf '\t\t\t\t' + echo "$cache: $(printf "%'d" $((CPU_CACHE_SIZES[$cache] >> 10))) KiB × ${CPU_NUM_CACHES[$cache]} ($(numfmt --to=iec-i "${CPU_TOTAL_CACHE_SIZES[$cache]}")B)" done fi @@ -154,13 +154,13 @@ TOTAL_SWAP=$(echo "$MEMINFO" | awk '/^SwapTotal:/ { print $2 }') echo -e "Total swap space:\t\t$(toiec "$TOTAL_SWAP") ($(tosi "$TOTAL_SWAP"))" DISKS=$(lsblk -dbn 2>/dev/null | awk '$6=="disk"') -if [[ -n "$DISKS" ]]; then - DISK_NAMES=( $(echo "$DISKS" | awk '{ print $1 }') ) - DISK_SIZES=( $(echo "$DISKS" | awk '{ print $4 }') ) +if [[ -n $DISKS ]]; then + DISK_NAMES=($(echo "$DISKS" | awk '{ print $1 }')) + DISK_SIZES=($(echo "$DISKS" | awk '{ print $4 }')) echo -e -n "Disk space:\t\t\t" for i in "${!DISK_NAMES[@]}"; do - (( i )) && printf '\t\t\t\t' - echo -e "${DISK_NAMES[i]}: $(printf "%'d" $(( DISK_SIZES[i] >> 20 ))) MiB$([[ ${DISK_SIZES[i]} -ge 1073741824 ]] && echo " ($(numfmt --to=iec-i "${DISK_SIZES[i]}")B)") ($(printf "%'d" $(( (DISK_SIZES[i] / 1000) / 1000 ))) MB$([[ ${DISK_SIZES[i]} -ge 1000000000 ]] && echo " ($(numfmt --to=si "${DISK_SIZES[i]}")B)"))" + ((i)) && printf '\t\t\t\t' + echo -e "${DISK_NAMES[i]}: $(printf "%'d" $((DISK_SIZES[i] >> 20))) MiB$([[ ${DISK_SIZES[i]} -ge 1073741824 ]] && echo " ($(numfmt --to=iec-i "${DISK_SIZES[i]}")B)") ($(printf "%'d" $(((DISK_SIZES[i] / 1000) / 1000))) MB$([[ ${DISK_SIZES[i]} -ge 1000000000 ]] && echo " ($(numfmt --to=si "${DISK_SIZES[i]}")B)"))" done fi @@ -170,7 +170,7 @@ for lspci in lspci /sbin/lspci; do break fi done -if [[ -n "$GPU" ]]; then +if [[ -n $GPU ]]; then echo -e "Graphics Processor (GPU):\t${GPU[0]}$([[ ${#GPU[*]} -gt 1 ]] && printf '\n\t\t\t\t%s' "${GPU[@]:1}")" fi @@ -179,7 +179,7 @@ echo -e "Computer name:\t\t\t$HOSTNAME" # uname -n # hostname # /proc/sys/kernel if command -v iwgetid >/dev/null; then NETWORKNAME=$(iwgetid -r || true) fi -if [[ -n "$NETWORKNAME" ]]; then +if [[ -n $NETWORKNAME ]]; then echo -e "Network name (SSID):\t\t$NETWORKNAME" fi @@ -187,41 +187,41 @@ HOSTNAME_FQDN=$(hostname -f) # hostname -A echo -e "Hostname:\t\t\t$HOSTNAME_FQDN" mapfile -t IPv4_ADDRESS < <(ip -o -4 a show up scope global | awk '{ print $2,$4 }') -if [[ -n "$IPv4_ADDRESS" ]]; then - IPv4_INERFACES=( $(printf '%s\n' "${IPv4_ADDRESS[@]}" | awk '{ print $1 }') ) - IPv4_ADDRESS=( $(printf '%s\n' "${IPv4_ADDRESS[@]}" | awk '{ print $2 }') ) +if [[ -n $IPv4_ADDRESS ]]; then + IPv4_INERFACES=($(printf '%s\n' "${IPv4_ADDRESS[@]}" | awk '{ print $1 }')) + IPv4_ADDRESS=($(printf '%s\n' "${IPv4_ADDRESS[@]}" | awk '{ print $2 }')) echo -e -n "IPv4 address$([[ ${#IPv4_ADDRESS[*]} -gt 1 ]] && echo "es"):\t\t\t" for i in "${!IPv4_INERFACES[@]}"; do - (( i )) && printf '\t\t\t\t' + ((i)) && printf '\t\t\t\t' echo -e "${IPv4_INERFACES[i]}: ${IPv4_ADDRESS[i]%/*}" done fi mapfile -t IPv6_ADDRESS < <(ip -o -6 a show up scope global | awk '{ print $2,$4 }') -if [[ -n "$IPv6_ADDRESS" ]]; then - IPv6_INERFACES=( $(printf '%s\n' "${IPv6_ADDRESS[@]}" | awk '{ print $1 }') ) - IPv6_ADDRESS=( $(printf '%s\n' "${IPv6_ADDRESS[@]}" | awk '{ print $2 }') ) +if [[ -n $IPv6_ADDRESS ]]; then + IPv6_INERFACES=($(printf '%s\n' "${IPv6_ADDRESS[@]}" | awk '{ print $1 }')) + IPv6_ADDRESS=($(printf '%s\n' "${IPv6_ADDRESS[@]}" | awk '{ print $2 }')) echo -e -n "IPv6 address$([[ ${#IPv6_ADDRESS[*]} -gt 1 ]] && echo "es"):\t\t\t" for i in "${!IPv6_INERFACES[@]}"; do - (( i )) && printf '\t\t\t\t' + ((i)) && printf '\t\t\t\t' echo -e "${IPv6_INERFACES[i]}: ${IPv6_ADDRESS[i]%/*}" done fi # ip -o l show up | grep -v 'loopback' | awk '{ print $2,$(NF-2) }' -INERFACES=( $(ip -o a show up primary scope global | awk '{ print $2 }' | uniq) ) +INERFACES=($(ip -o a show up primary scope global | awk '{ print $2 }' | uniq)) NET_INERFACES=() NET_ADDRESSES=() for inerface in "${INERFACES[@]}"; do file="/sys/class/net/$inerface" if [[ -r "$file/address" ]]; then - NET_INERFACES+=( "$inerface" ) - NET_ADDRESSES+=( "$(<"$file/address")" ) + NET_INERFACES+=("$inerface") + NET_ADDRESSES+=("$(<"$file/address")") fi done -if [[ -n "$NET_INERFACES" ]]; then +if [[ -n $NET_INERFACES ]]; then echo -e -n "MAC address$([[ ${#NET_INERFACES[*]} -gt 1 ]] && echo "es"):\t\t\t" for i in "${!NET_INERFACES[@]}"; do - (( i )) && printf '\t\t\t\t' + ((i)) && printf '\t\t\t\t' echo -e "${NET_INERFACES[i]}: ${NET_ADDRESSES[i]}" done fi @@ -232,7 +232,7 @@ if [[ -r /var/lib/dbus/machine-id ]]; then fi TIME_ZONE=$(timedatectl 2>/dev/null | grep -i 'time zone:\|timezone:' | sed -n 's/^.*: //p') # timedatectl show --value -p Timezone -if [[ -z "$TIME_ZONE" ]]; then +if [[ -z $TIME_ZONE ]]; then if [[ -r /etc/timezone ]]; then TIME_ZONE=$(&1); then diff --git a/typeinfo.sh b/typeinfo.sh index 30ecc93..e64372b 100644 --- a/typeinfo.sh +++ b/typeinfo.sh @@ -18,14 +18,14 @@ if ! command -v g++ >/dev/null; then exit 1 fi -if [[ -n "$CXX" ]] && ! command -v "$CXX" >/dev/null; then +if [[ -n $CXX ]] && ! command -v "$CXX" >/dev/null; then echo "Error: $CXX is not installed." >&2 exit 1 fi CXX=${CXX:-g++} -cat << EOF > /tmp/types.cpp +cat </tmp/types.cpp #include #include #include