Skip to content

Commit d4ae5d2

Browse files
committed
raspinfo: remove bashisms and use POSIX sh
This removes bash as dependency for downstream packagers. Workaround 3 bashisms: - &> - == test - process substitution for log file
1 parent f05444f commit d4ae5d2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

raspinfo/raspinfo

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# Some of the regex's used in sed
44
# Catch basic IP6 address "s/\([0-9a-fA-F]\{1,4\}:\)\{7,7\}[0-9a-fA-F]\{1,4\}/y.y.y.y.y.y.y.y/g"
@@ -68,7 +68,7 @@ display_info_drm() {
6868
cardfound=1
6969
fi
7070
done
71-
if [ "$cardfound" == "0" ];
71+
if [ "$cardfound" = "0" ];
7272
then
7373
echo "kms state not found"
7474
echo
@@ -115,7 +115,7 @@ display_info_legacy() {
115115

116116
if pgrep Xorg > /dev/null &&
117117
command -v xrandr > /dev/null &&
118-
DISPLAY=${DISPLAY:-:0} xrandr --listmonitors &>/dev/null; then
118+
DISPLAY=${DISPLAY:-:0} xrandr --listmonitors >/dev/null 2>&1; then
119119
DISPLAY=${DISPLAY:-:0} xrandr --verbose
120120
echo
121121
fi
@@ -171,7 +171,11 @@ OUT=raspinfo.txt
171171

172172
rm -f $OUT
173173

174-
exec > >(tee -ia $OUT)
174+
# avoid process substition bashism to generate logfile
175+
PIPE_PATH=$(mktemp -u)
176+
mkfifo $PIPE_PATH
177+
tee -ia $OUT < $PIPE_PATH &
178+
exec > $PIPE_PATH
175179

176180
echo "System Information"
177181
echo "------------------"

0 commit comments

Comments
 (0)