File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ REPO_NAME="lab0-c"
65
65
repo_html=$( curl -s " https://github.com/${REPO_OWNER} /${REPO_NAME} " )
66
66
67
67
# 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)
69
69
70
70
if [ " $DEFAULT_BRANCH " != " master" ]; then
71
71
echo " $DEFAULT_BRANCH "
@@ -80,8 +80,7 @@ curl -sSL -o "$temp_file" "$COMMITS_URL"
80
80
81
81
# general grep pattern that finds commit links
82
82
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
85
84
)
86
85
87
86
rm -f " $temp_file "
Original file line number Diff line number Diff line change @@ -89,14 +89,14 @@ make_random_string() {
89
89
90
90
if [ -z " $sub_str " ]; then
91
91
# 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 "
93
93
else
94
94
# Insert the substring at a random position
95
95
local sub_len=${# sub_str}
96
96
local rand_len=$(( total_len - sub_len ))
97
97
98
98
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 " )
100
100
101
101
local pos=$(( RANDOM % (rand_len + 1 ) ))
102
102
echo " ${raw_rand: 0: pos}${sub_str}${raw_rand: pos} "
You can’t perform that action at this time.
0 commit comments