Add release script, fix sed for MacOS
[policy/parent.git] / integration / src / release_scripts / updateParentRef.sh
index 831d6c3..0f10cfb 100755 (executable)
@@ -4,7 +4,7 @@
 # ============LICENSE_START================================================
 # ONAP
 # =========================================================================
-# Copyright (C) 2021 Nordix Foundation.
+# Copyright (C) 2021-2022 Nordix Foundation.
 # =========================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # ============LICENSE_END==================================================
 #
 
+set -e
+
 SCRIPT_NAME=`basename $0`
 
+# Use the bash internal OSTYPE variable to check for MacOS
+if [[ "$OSTYPE" == "darwin"* ]]
+then
+    SED="gsed"
+else
+    SED="sed"
+fi
+
 usage()
 {
     echo ""
@@ -97,9 +107,9 @@ then
     exit 1
 fi
 
-pom_lines=`wc -l $pom_file | sed 's/^[ \t]*//' | cut -f1 -d' '`
-parent_start_line=`grep -n '^[\t ]*<parent>[\t*]*$' $pom_file | cut -f1 -d':'`
-parent_end_line=`grep -n '^[\t ]*</parent>[\t*]*$' $pom_file | cut -f1 -d':'`
+pom_lines=`wc -l $pom_file | $SED 's/^[ \t]*//' | cut -f1 -d' '`
+parent_start_line=`grep -n '^[\t ]*<parent>[\t ]*$' $pom_file | cut -f1 -d':'`
+parent_end_line=`grep -n '^[\t ]*</parent>[\t ]*$' $pom_file | cut -f1 -d':'`
 
 pom_head_lines=$((parent_start_line-1))
 pom_tail_lines=$((pom_lines-parent_end_line))