Skip to content

Commit

Permalink
make venvShellHook compatible with sh (#2333)
Browse files Browse the repository at this point in the history
## Summary

Fix #2329 by using a more minimal posix set in the venvShellHook

## How was it tested?

Verified using `sh ./venvShellHook.sh` locally
  • Loading branch information
Lagoja authored Oct 8, 2024
1 parent 750bfc1 commit 14327a7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions plugins/python/venvShellHook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ create_venv() {

# Check that Python version supports venv
if ! python -c 'import venv' 1> /dev/null 2> /dev/null; then
echo "\033[1;33mWARNING: Python version must be > 3.3 to create a virtual environment.\033[0m"
echo "WARNING: Python version must be > 3.3 to create a virtual environment."
touch "$STATE_FILE"
exit 1
fi
Expand All @@ -31,15 +31,19 @@ if [ -d "$VENV_DIR" ]; then
exit 0
fi
if ! is_devbox_venv "$VENV_DIR"; then
echo "\033[1;33mWARNING: Virtual environment at $VENV_DIR doesn't use Devbox Python.\033[0m"
read -p "Do you want to overwrite it? (y/n) " -n 1 -r
echo "WARNING: Virtual environment at $VENV_DIR doesn't use Devbox Python."
echo "Do you want to overwrite it? (y/n)"
read reply
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [[ $reply =~ ^[Yy]$ ]]; then
echo "Overwriting existing virtual environment..."
create_venv
else
elif [[ $reply =~ ^[Nn]$ ]]; then
echo "Using your existing virtual environment. We recommend changing \$VENV_DIR to a different location"
touch "$STATE_FILE"
exit 0
else
echo "Invalid input. Exiting..."
exit 1
fi
fi
Expand Down

0 comments on commit 14327a7

Please sign in to comment.