Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract out sed -i parameter for macos in repro_common.sh #4015

Open
sxa opened this issue Oct 29, 2024 · 0 comments
Open

Abstract out sed -i parameter for macos in repro_common.sh #4015

sxa opened this issue Oct 29, 2024 · 0 comments
Labels
good first issue Issues that have been deemed "easy" and excellent for new contributors macos Issues that affect or relate to the MAC OS

Comments

@sxa
Copy link
Member

sxa commented Oct 29, 2024

At the moment we have blocks like this in repro_common.sh:

if [[ $(uname) =~ Darwin* ]]; then
    echo "Removing Temurin specific lines from release file in $DIR"
    sed -i "" '/^BUILD_SOURCE=.*$/d' "${DIR}/release"
    sed -i "" '/^BUILD_SOURCE_REPO=.*$/d' "${DIR}/release"
[...]
    echo "Removing SOURCE= from ${DIR}/release file, as Temurin builds from Adoptium mirror repo _adopt tag"
    sed -i "" '/^SOURCE=.*$/d' "${DIR}/release"
else
    echo "Removing Temurin specific lines from release file in $DIR"
    sed -i '/^BUILD_SOURCE=.*$/d' "${DIR}/release"
    sed -i '/^BUILD_SOURCE_REPO=.*$/d' "${DIR}/release"
[...]
fi

A nicer solution would be to use multiple -e parameters to sed (I'm assuming that will be find on macos too) and use a variable to switch between the two parameter formats in order to avoid code duplication e.g:

if [ $(uname) = "Darwin" ]; then
   SED_INLINE='-i ""'
else
  SED_INLINE="-i"
fi
    echo "Removing Temurin specific lines from release file in $DIR"
    sed $SED_INLINE '/^BUILD_SOURCE=.*$/d' "${DIR}/release"
    sed $SED_INLINE '/^BUILD_SOURCE_REPO=.*$/d' "${DIR}/release"
[...]
@sxa sxa added the good first issue Issues that have been deemed "easy" and excellent for new contributors label Oct 29, 2024
@github-actions github-actions bot added the macos Issues that affect or relate to the MAC OS label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that have been deemed "easy" and excellent for new contributors macos Issues that affect or relate to the MAC OS
Projects
Status: Todo
Development

No branches or pull requests

1 participant