Skip to content

Commit

Permalink
Changes to the way sed is checked
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna Kumar <krishnakumar@ibm.com>
  • Loading branch information
krishnakumar27 committed Mar 30, 2022
1 parent 140d05f commit aba3a61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
17 changes: 6 additions & 11 deletions api/codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,13 @@ swagger-codegen generate -i swagger/swagger.yaml -l python-flask -o server 2>&1
# set interactive mode to enable defining a gsed alias
shopt -s expand_aliases

# we use sed to make in-file text replacements, but sed works differently on macOS and Linux
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
alias gsed="sed -i"
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
alias gsed="sed -i ''"
elif [[ "$OSTYPE" == "cygwin" ]]; then # POSIX compatible emulation for Windows
alias gsed="sed -i"
elif [[ "$OSTYPE" == "msys"* ]]; then # Git Bash (Windows)
alias gsed="sed -i"
# we use sed to make in-file text replacements, but sed works differently depending on the version
if ! sed -i '1s/^/test/' $(mktemp) 2> /dev/null; then
# macOS (BSD) version of sed
alias gsed="sed -i ''"
else
echo "FAILED. OS not compatible with script '${BASH_SOURCE[0]}'"
exit 1
# POSIX compliant version of sed
alias gsed="sed -i"
fi
export gsed

Expand Down
17 changes: 7 additions & 10 deletions tools/bash/add_license_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
# set interactive mode to enable defining a gsed alias
shopt -s expand_aliases

if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
alias gsed="sed -i"
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
alias gsed="sed -i ''"
elif [[ "$OSTYPE" == "cygwin" ]]; then # POSIX compatible emulation for Windows
alias gsed="sed -i"
elif [[ "$OSTYPE" == "msys"* ]]; then # Git Bash (Windows)
alias gsed="sed -i"
# we use sed to make in-file text replacements, but sed works differently depending on the version
if ! sed -i '1s/^/test/' $(mktemp) 2> /dev/null; then
# macOS (BSD) version of sed
alias gsed="sed -i ''"
else
echo "FAILED. OS not compatible with script '${BASH_SOURCE[0]}'"
exit 1
# POSIX compliant version of sed
alias gsed="sed -i"
fi

export gsed

hash_comment () {
Expand Down

0 comments on commit aba3a61

Please sign in to comment.