Skip to content

Commit 8e0d2f2

Browse files
committed
chore(init): remove unnecessary parsing logic
We can get the values we need directly from stat. No need to do goofy string parsing ourselves. Signed-off-by: Randolph Sapp <[email protected]>
1 parent ab6ac37 commit 8e0d2f2

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

docker/root/init

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,12 @@
33
# SPDX-License-Identifier: MIT
44
# Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com
55

6-
get_attribs() {
7-
local file_stats file_to_test useful_attribs
8-
if file_to_test=$(realpath "$1") && [[ $2 =~ ^[0-9]+$ ]] ; then
9-
useful_attribs=$(stat "$file_to_test" -t)
10-
read -r -a file_stats <<< "${useful_attribs#"$file_to_test"}"
11-
echo "${file_stats["$2"]}"
12-
else
13-
return 1
14-
fi
15-
}
16-
176
get_build_uid() {
18-
get_attribs /build 3
7+
stat -c '%u' /build
198
}
209

2110
get_build_gid() {
22-
get_attribs /build 4
11+
stat -c '%g' /build
2312
}
2413

2514
if NEW_GID=$(get_build_gid) && NEW_UID=$(get_build_uid); then

0 commit comments

Comments
 (0)