aboutsummaryrefslogtreecommitdiffstats
path: root/tools/execute_sql_code.sh
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-11-16 11:09:40 +0800
committerGitHub <noreply@github.com>2024-11-16 11:09:40 +0800
commit86aa9106090a0219bac30bc12f5a5bd91949afd9 (patch)
tree69aef8c03242c67480c4edfe42a2cbf4c785b466 /tools/execute_sql_code.sh
parent6d30c22b82a5ac1a5775d8137c3b08a581770273 (diff)
downloadllm-functions-docker-86aa9106090a0219bac30bc12f5a5bd91949afd9.tar.gz
refactor: improve bash code (#125)
* refactor: extract guard_path to utils/guard_path.sh * add utils/guard_operation.sh
Diffstat (limited to 'tools/execute_sql_code.sh')
-rwxr-xr-xtools/execute_sql_code.sh10
1 files changed, 3 insertions, 7 deletions
diff --git a/tools/execute_sql_code.sh b/tools/execute_sql_code.sh
index df57dea..34cd948 100755
--- a/tools/execute_sql_code.sh
+++ b/tools/execute_sql_code.sh
@@ -9,15 +9,11 @@ set -e
# @env USQL_DSN! The database url, e.g. pgsql://user:pass@host/dbname
# @env LLM_OUTPUT=/dev/stdout The output path
+ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
+
main() {
if ! grep -qi '^select' <<<"$argc_code"; then
- if [ -t 1 ]; then
- read -r -p "Are you sure you want to continue? [Y/n] " ans
- if [[ "$ans" == "N" || "$ans" == "n" ]]; then
- echo "Aborted!"
- exit 1
- fi
- fi
+ "$ROOT_DIR/utils/guard_operation.sh"
fi
usql -c "$argc_code" "$USQL_DSN" >> "$LLM_OUTPUT"
}