Skip to content

Commit b36c6b1

Browse files
authored
Merge pull request #245 from sysprog21/fix-bsd-compatibility
Fix BSD compatibility
2 parents 0354ec7 + 572dd8f commit b36c6b1

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

scripts/check-repo.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ REPO_NAME="lab0-c"
6565
repo_html=$(curl -s "https://github.com/${REPO_OWNER}/${REPO_NAME}")
6666

6767
# Extract the default branch name from data-default-branch="..."
68-
DEFAULT_BRANCH=$(echo "$repo_html" | grep -oP "/${REPO_OWNER}/${REPO_NAME}/blob/\K[^/]+(?=/LICENSE)" | head -n 1)
68+
DEFAULT_BRANCH=$(echo "$repo_html" | sed -nE "s#.*${REPO_OWNER}/${REPO_NAME}/blob/([^/]+)/LICENSE.*#\1#p" | head -n 1)
6969

7070
if [ "$DEFAULT_BRANCH" != "master" ]; then
7171
echo "$DEFAULT_BRANCH"
@@ -80,8 +80,7 @@ curl -sSL -o "$temp_file" "$COMMITS_URL"
8080

8181
# general grep pattern that finds commit links
8282
upstream_hash=$(
83-
grep -Po 'href="[^"]*/commit/\K[0-9a-f]{40}' "$temp_file" \
84-
| head -n 1
83+
sed -nE 's/.*href="[^"]*\/commit\/([0-9a-f]{40}).*/\1/p' "$temp_file" | head -n 1
8584
)
8685

8786
rm -f "$temp_file"

scripts/common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ make_random_string() {
8989

9090
if [ -z "$sub_str" ]; then
9191
# Produce an exact random string of length total_len
92-
cat /dev/urandom | tr -dc 'a-z0-9' | head -c "$total_len"
92+
cat /dev/urandom | LC_ALL=C tr -dc 'a-z0-9' | head -c "$total_len"
9393
else
9494
# Insert the substring at a random position
9595
local sub_len=${#sub_str}
9696
local rand_len=$(( total_len - sub_len ))
9797

9898
local raw_rand
99-
raw_rand=$(cat /dev/urandom | tr -dc 'a-z0-9' | head -c "$rand_len")
99+
raw_rand=$(cat /dev/urandom | LC_ALL=C tr -dc 'a-z0-9' | head -c "$rand_len")
100100

101101
local pos=$(( RANDOM % (rand_len + 1) ))
102102
echo "${raw_rand:0:pos}${sub_str}${raw_rand:pos}"

0 commit comments

Comments
 (0)