sed failure
#234
Replies: 2 comments 2 replies
-
|
The BSD sed word boundary syntax [[:<:]] and [[:>:]] was causing the "Invalid character class name" error with GNU sed. Thanks cursor! On to the workshop |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
If you want to have this fixed ASAP, you can apply this patch: diff --git a/scripts/common-functions.sh b/scripts/common-functions.sh
index 0648367..baf9848 100755
--- a/scripts/common-functions.sh
+++ b/scripts/common-functions.sh
@@ -1284,6 +1284,18 @@ convert_filename_to_human_name() {
# Convert to lowercase first
name=$(echo "$name" | tr '[:upper:]' '[:lower:]')
+ IS_GNU_SED=$(sed --version 2>/dev/null | grep -q "GNU sed" && echo TRUE || echo FALSE)
+
+ if [ $IS_GNU_SED = 'TRUE' ]; then
+ # Use \b GNU sed word boundaries
+ WORD_OPEN="\b"
+ WORD_CLOSE="\b"
+ else
+ # Use [[:<:]] and [[:>:]] for BSD sed word boundaries
+ WORD_OPEN="[[:<:]]"
+ WORD_CLOSE="[[:>:]]"
+ fi
+
# Replace known acronyms with uppercase version
# Match all case variations: lowercase, Capitalized, UPPERCASE
for acronym in "${acronyms[@]}"; do
@@ -1291,10 +1303,9 @@ convert_filename_to_human_name() {
local capitalized=$(echo "$lowercase" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')
# Replace all variations with the uppercase acronym
- # Use [[:<:]] and [[:>:]] for BSD sed word boundaries
- name=$(echo "$name" | sed -E "s/[[:<:]]$lowercase[[:>:]]/$acronym/g")
- name=$(echo "$name" | sed -E "s/[[:<:]]$capitalized[[:>:]]/$acronym/g")
- name=$(echo "$name" | sed -E "s/[[:<:]]$acronym[[:>:]]/$acronym/g")
+ name=$(echo "$name" | sed -E "s/$WORD_OPEN$lowercase$WORD_CLOSE/$acronym/g")
+ name=$(echo "$name" | sed -E "s/$WORD_OPEN$capitalized$WORD_CLOSE/$acronym/g")
+ name=$(echo "$name" | sed -E "s/$WORD_OPEN$acronym$WORD_CLOSE/$acronym/g")
done
echo "$name"
@@ -1320,6 +1331,18 @@ convert_filename_to_human_name_capitalized() {
# Capitalize first letter of each word
name=$(echo "$name" | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
+ IS_GNU_SED=$(sed --version 2>/dev/null | grep -q "GNU sed" && echo TRUE || echo FALSE)
+
+ if [ $IS_GNU_SED = 'TRUE' ]; then
+ # Use \b GNU sed word boundaries
+ WORD_OPEN="\b"
+ WORD_CLOSE="\b"
+ else
+ # Use [[:<:]] and [[:>:]] for BSD sed word boundaries
+ WORD_OPEN="[[:<:]]"
+ WORD_CLOSE="[[:>:]]"
+ fi
+
# Replace known acronyms with uppercase version
# Match all case variations: lowercase, Capitalized, UPPERCASE
for acronym in "${acronyms[@]}"; do
@@ -1327,10 +1350,9 @@ convert_filename_to_human_name_capitalized() {
local capitalized=$(echo "$lowercase" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')
# Replace all variations with the uppercase acronym
- # Use [[:<:]] and [[:>:]] for BSD sed word boundaries
- name=$(echo "$name" | sed -E "s/[[:<:]]$lowercase[[:>:]]/$acronym/g")
- name=$(echo "$name" | sed -E "s/[[:<:]]$capitalized[[:>:]]/$acronym/g")
- name=$(echo "$name" | sed -E "s/[[:<:]]$acronym[[:>:]]/$acronym/g")
+ name=$(echo "$name" | sed -E "s/$WORD_OPEN$lowercase$WORD_CLOSE/$acronym/g")
+ name=$(echo "$name" | sed -E "s/$WORD_OPEN$capitalized$WORD_CLOSE/$acronym/g")
+ name=$(echo "$name" | sed -E "s/$WORD_OPEN$acronym$WORD_CLOSE/$acronym/g")
done
echo "$name"
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Just updated to 2.1.0 in preparation for workshop in 30 minutes.
Base installation ran fine.
Project installation detects existing 2.0.0 agent-os and then loops with a failed sed command over and over
Does the same for project-install as project-update
I'm running on a macbook
Beta Was this translation helpful? Give feedback.
All reactions