blob: 891267e4b88d76048780556eb161d2cff8623bfb (
plain)
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
53
54
55
56
57
58
59
60
61
62
|
From dd8a42d142a638de08cb6ea7483e33b27fe221b5 Mon Sep 17 00:00:00 2001
From: Alexander Tsoy <alexander@tsoy.me>
Date: Thu, 19 Jun 2025 18:10:04 +0300
Subject: [PATCH] mkpak.sh: use more portable shell
At least it now works in dash
---
Misc/qs_pak/mkpak.sh | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/Misc/qs_pak/mkpak.sh b/Misc/qs_pak/mkpak.sh
index e6562bf9..dbfd9eb5 100755
--- a/Misc/qs_pak/mkpak.sh
+++ b/Misc/qs_pak/mkpak.sh
@@ -39,7 +39,7 @@ assert_valid_file() {
then
error "$1: Permission denied"
fi
- if test $(echo -n "$1" | wc -c) -gt 55
+ if test $(printf '%s' "$1" | wc -c) -gt 55
then
error "$1: Name too long"
fi
@@ -53,15 +53,11 @@ assert_valid_int32() {
}
octal() {
- if test $1 -gt 7
- then
- octal $(expr $1 / 8)
- fi
- echo -n $(expr $1 % 8)
+ printf '%o' $1
}
byte() {
- echo -en \\0$(octal $1)
+ printf '%b' "\\0$(octal $1)"
}
little_endian_uint32() {
@@ -90,14 +86,14 @@ zero_padding() {
}
header() {
- echo -n PACK
+ printf '%s' PACK
little_endian_int32 $1
little_endian_int32 $2
}
directory_entry() {
- echo -n "$1"
- zero_padding $(expr 56 - $(echo -n "$1" | wc -c))
+ printf '%s' "$1"
+ zero_padding $(expr 56 - $(printf '%s' "$1" | wc -c))
little_endian_int32 $2
little_endian_int32 $3
}
--
2.49.0
|