Skip to content

Commit

Permalink
Fix: Use in-place edit option that works for Linux, macOS, and OpenBSD
Browse files Browse the repository at this point in the history
Signed-off-by: Wenxuan Zhao <viz@linux.com>
  • Loading branch information
vizv committed Apr 1, 2018
1 parent bbf47a4 commit d0527d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/install_host_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,16 @@ else
curl -sSL "$MANIFEST_URL" > "$MANIFEST_FILE_PATH"
fi

if [ "$KERNEL_NAME" == 'Darwin' ] || [ "$IS_BSD" = true ]; then
# Use BSD style sed on macOS and BSD systems
# When using sed on macOS, backup extension is an mandatory argument
# whereas on GNU sed or BSD sed backup extension may be omit.
if [ "$KERNEL_NAME" == 'Darwin' ]; then
# Replace path to python3 executable
/usr/bin/sed -i '' "1 s@.*@#\!${PYTHON3_PATH}@" "$HOST_FILE_PATH"
# Replace path to host
/usr/bin/sed -i '' -e "s/PLACEHOLDER/$ESCAPED_HOST_FILE_PATH/" "$MANIFEST_FILE_PATH"
else
# Replace path to python3 executable
sed -i "1c#\!${PYTHON3_PATH}" "$HOST_FILE_PATH"
sed -i "1 s@.*@#\!${PYTHON3_PATH}@" "$HOST_FILE_PATH"
# Replace path to host
sed -i -e "s/PLACEHOLDER/$ESCAPED_HOST_FILE_PATH/" "$MANIFEST_FILE_PATH"
fi
Expand Down

0 comments on commit d0527d8

Please sign in to comment.