File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,24 @@ DOCKER_COLLECTOR_CONFIG_CLOUD='./src/otel-collector/otelcol-elastic-config.yaml'
2424DOCKER_COLLECTOR_CONFIG_SERVERLESS=' ./src/otel-collector/otelcol-elastic-otlp-config.yaml'
2525COLLECTOR_CONTRIB_IMAGE=docker.elastic.co/elastic-agent/elastic-agent:$ELASTIC_STACK_VERSION
2626
27+ # Detect sed variant: GNU sed uses --version, BSD sed doesn't
28+ # GNU sed: sed -i (no empty string needed)
29+ # BSD sed: sed -i '' (empty string required)
30+ if sed --version > /dev/null 2>&1 ; then
31+ SED_IS_BSD=" false"
32+ else
33+ SED_IS_BSD=" true"
34+ fi
35+
36+ # Portable sed in-place editing function
37+ # Usage: sed_in_place "s/pattern/replacement/g" file
38+ sed_in_place () {
39+ if [ " $SED_IS_BSD " = " true" ]; then
40+ sed -i ' ' " $@ "
41+ else
42+ sed -i " $@ "
43+ fi
44+ }
2745
2846# Variables
2947deployment_type=" "
@@ -60,7 +78,7 @@ update_env_var() {
6078 VAR=" $1 "
6179 VAL=" $2 "
6280 if grep -q " ^$VAR =" " $ENV_OVERRIDE_FILE " ; then
63- sed -i ' ' " s|^$VAR =.*|$VAR =\" $VAL \" |" " $ENV_OVERRIDE_FILE "
81+ sed_in_place " s|^$VAR =.*|$VAR =\" $VAL \" |" " $ENV_OVERRIDE_FILE "
6482 else
6583 echo " $VAR =\" $VAL \" " >> " $ENV_OVERRIDE_FILE "
6684 fi
@@ -241,4 +259,4 @@ main() {
241259 echo " 🎉 OTel Demo and EDOT are running on '$platform '; data is flowing to Elastic ($deployment_type )."
242260}
243261
244- main " $@ "
262+ main " $@ "
You can’t perform that action at this time.
0 commit comments