-
Notifications
You must be signed in to change notification settings - Fork 0
/
0001-dthelper-improve-compatibility-with-real-bash.patch
53 lines (45 loc) · 1.81 KB
/
0001-dthelper-improve-compatibility-with-real-bash.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From eda3c796c30fcdb0688594d8f7d6934dc9dcbf79 Mon Sep 17 00:00:00 2001
From: Yuntian Zhang <[email protected]>
Date: Fri, 22 Apr 2022 17:48:10 +0800
Subject: [PATCH] dthelper: improve compatibility with real bash
busybox's bash and GNU bash handles '\0' in stdout differently, and
the script will output incorrect result due to this.
Signed-off-by: Yuntian Zhang <[email protected]>
---
packages/sysutils/busybox/scripts/dthelper | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/packages/sysutils/busybox/scripts/dthelper b/packages/sysutils/busybox/scripts/dthelper
index a60e6b95f4..624a8c9ab8 100755
--- a/packages/sysutils/busybox/scripts/dthelper
+++ b/packages/sysutils/busybox/scripts/dthelper
@@ -20,7 +20,7 @@ do_dtfile(){
do_dtflag(){
if [ "${COMPATIBLE}" = "raspberrypi" ]; then
- DTFLAG=$(cat /proc/device-tree/compatible | cut -f1,2 -d',' | head -n 1)
+ DTFLAG=$(tr '\0' '\n' < /proc/device-tree/compatible | head -n 1)
PIREV=$(awk '/^Revision/ {sub($3,-6, "", $3); print $3}' /proc/cpuinfo) # truncate to 6-chars
case "${PIREV}" in
d*)
@@ -46,7 +46,7 @@ do_dtflag(){
;;
esac
else
- DTFLAG=$(cat /proc/device-tree/compatible | cut -f1,2 -d',' | head -n 1)
+ DTFLAG=$(tr '\0' '\n' < /proc/device-tree/compatible | head -n 1)
MEMSIZE=$(awk -F " " '/MemTotal:/ {print $2}' /proc/meminfo)
if [ "${MEMSIZE}" -lt "524288" ]; then
MEMSIZE="-512"
@@ -58,12 +58,12 @@ do_dtflag(){
}
do_dtname(){
- DTNAME=$(cat /proc/device-tree/compatible | cut -f1,2 -d',' | head -n 1)
+ DTNAME=$(tr '\0' '\n' < /proc/device-tree/compatible | head -n 1)
echo "${DTNAME}"
}
do_dtsoc(){
- DTSOC=$(cat /proc/device-tree/compatible | cut -f1,2 -d',' | tail -n 1)
+ DTSOC=$(tr '\0' '\n' < /proc/device-tree/compatible | tail -n 1)
echo "${DTSOC}"
}
--
2.35.1