Skip to content

Commit 1d33ec7

Browse files
committed
Ensure consistent sort order using LC_ALL=C
> *** WARNING *** The locale specified by the environment affects sort > order. Set LC_ALL=C to get the traditional sort order that uses native > byte values. > — `man sort`
1 parent 56be7e9 commit 1d33ec7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

generateIndices.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
ROOT_DIR="./src"
44

5-
LC_ALL=C
6-
75
generate_indices() {
86
local dir="$1"
97
local index_file="$dir/index.ts"
108

119
local -a ts_files
12-
mapfile -t ts_files < <(find "$dir" -maxdepth 1 -type f -name "*.ts" ! -name "index.ts" | sort)
10+
mapfile -t ts_files < <(find "$dir" -maxdepth 1 -type f -name "*.ts" ! -name "index.ts" | LC_ALL=C sort)
1311
if [[ ${#ts_files[@]} -eq 0 ]]; then
1412
return
1513
fi
@@ -24,7 +22,7 @@ generate_indices() {
2422
done
2523

2624
local -a subdirs
27-
mapfile -t subdirs < <(find "$dir" -mindepth 1 -maxdepth 1 -type d | sort)
25+
mapfile -t subdirs < <(find "$dir" -mindepth 1 -maxdepth 1 -type d | LC_ALL=C sort)
2826
for subdir in "${subdirs[@]}"; do
2927
generate_indices "$subdir"
3028
done

0 commit comments

Comments
 (0)