This is an automated email from the ASF dual-hosted git repository.
snazy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 936991159 Simplify `polaris` client script (#1220)
936991159 is described below
commit 936991159bf2bcb4d9453b74ac6246553e2bf430
Author: Robert Stupp <[email protected]>
AuthorDate: Sat Mar 22 10:13:03 2025 +0100
Simplify `polaris` client script (#1220)
Address [SC2164](https://github.com/koalaman/shellcheck/wiki/SC2164),
[SC2098](https://github.com/koalaman/shellcheck/wiki/SC2098),
[SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)
Co-authored-by: Alexandre Dutra <[email protected]>
---
polaris | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/polaris b/polaris
index e665139aa..b3ea7f82c 100755
--- a/polaris
+++ b/polaris
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,29 +17,24 @@
# specific language governing permissions and limitations
# under the License.
#
-SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
-if [ ! -d ${SCRIPT_DIR}/polaris-venv ]; then
+set -e
+
+dir=${0%/*}
+
+if [ ! -d "${dir}"/polaris-venv ]; then
echo "Performing first-time setup for the Python client..."
- rm -f ${SCRIPT_DIR}/poetry.lock
- python3 -m venv ${SCRIPT_DIR}/polaris-venv
- . ${SCRIPT_DIR}/polaris-venv/bin/activate
+ rm -f "${dir}"/poetry.lock
+ python3 -m venv "${dir}"/polaris-venv
+ . "${dir}"/polaris-venv/bin/activate
pip install -r regtests/requirements.txt
- cp ${SCRIPT_DIR}/client/python/pyproject.toml ${SCRIPT_DIR}
- pushd $SCRIPT_DIR && poetry install ; popd
+ cp "${dir}"/client/python/pyproject.toml "${dir}"
+ pushd "$dir" && poetry install ; popd
deactivate
echo "First time setup complete."
fi
-pushd $SCRIPT_DIR > /dev/null
-PYTHONPATH=client/python SCRIPT_DIR="$SCRIPT_DIR"
${SCRIPT_DIR}/polaris-venv/bin/python3 client/python/cli/polaris_cli.py "$@"
-status=$?
-popd > /dev/null
-
-if [ $status -ne 0 ]; then
- exit 1
-fi
-
-exit 0
+cd "$dir"
+env PYTHONPATH=client/python SCRIPT_DIR="$dir"
"${dir}"/polaris-venv/bin/python3 client/python/cli/polaris_cli.py "$@"