Skip to content

Commit c4f508a

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 a8ff215 commit c4f508a

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"
@@ -11,7 +11,7 @@ display_info_drm() {
1111
# If running X then can use xrandr, otherwise
1212
# dump the /sys/class entries for the displays
1313
if command -v xrandr > /dev/null &&
14-
DISPLAY=${DISPLAY:-:0} xrandr --listmonitors &>/dev/null;
14+
DISPLAY=${DISPLAY:-:0} xrandr --listmonitors >/dev/null 2>&1;
1515
then
1616
echo "Running (F)KMS and X"
1717
echo
@@ -77,7 +77,7 @@ display_info_drm() {
7777
cardfound=1
7878
fi
7979
done
80-
if [ "$cardfound" == "0" ];
80+
if [ "$cardfound" = "0" ];
8181
then
8282
echo "kms state not found"
8383
fi
@@ -137,7 +137,11 @@ OUT=raspinfo.txt
137137

138138
rm -f $OUT
139139

140-
exec > >(tee -ia $OUT)
140+
# avoid process substition bashism to generate logfile
141+
PIPE_PATH=$(mktemp -u)
142+
mkfifo $PIPE_PATH
143+
tee -ia $OUT < $PIPE_PATH &
144+
exec > $PIPE_PATH
141145

142146
echo "System Information"
143147
echo "------------------"

0 commit comments

Comments
 (0)