diff options
| author | sigoden <sigoden@gmail.com> | 2024-08-17 12:40:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-17 12:40:32 +0800 |
| commit | 760ea38fed35ed12b431faa538f4ed6269a1c174 (patch) | |
| tree | 23e9bace88b0f59133ee4303c7103c71f62f87af | |
| parent | a53ca4fda2760cdf60d572daad8fd631f41b5a9a (diff) | |
| download | llm-functions-docker-760ea38fed35ed12b431faa538f4ed6269a1c174.tar.gz | |
refactor: improve `fs_*` (#99)
improve `_guard_path` to use `realpath -m <path>` to get absolute path
| -rw-r--r-- | Argcfile.sh | 1 | ||||
| -rwxr-xr-x | agents/coder/tools.sh | 3 | ||||
| -rwxr-xr-x | tools/fs_rm.sh | 2 | ||||
| -rwxr-xr-x | tools/fs_write.sh | 2 |
4 files changed, 5 insertions, 3 deletions
diff --git a/Argcfile.sh b/Argcfile.sh index cb4baec..0ffebd3 100644 --- a/Argcfile.sh +++ b/Argcfile.sh @@ -502,6 +502,7 @@ version() { fi argc --argc-version jq --version + ls --version 2>&1 | head -n 1 for item in "${LANG_CMDS[@]}"; do cmd="${item#*:}" if [[ "$cmd" == "bash" ]]; then diff --git a/agents/coder/tools.sh b/agents/coder/tools.sh index 15a3208..0001c46 100755 --- a/agents/coder/tools.sh +++ b/agents/coder/tools.sh @@ -6,6 +6,7 @@ set -e # @option --contents! The contents of the file fs_create() { _guard_path "$argc_path" Create + mkdir -p "$(dirname "$argc_path")" printf "%s" "$argc_contents" > "$argc_path" echo "File created: $argc_path" >> "$LLM_OUTPUT" } @@ -44,7 +45,7 @@ fs_edit() { } _guard_path() { - path="$(realpath "$1")" + path="$(realpath -m "$1")" action="$2" if [[ ! "$path" == "$(pwd)"* ]]; then if [ -t 1 ]; then diff --git a/tools/fs_rm.sh b/tools/fs_rm.sh index 89e9f95..77b5cee 100755 --- a/tools/fs_rm.sh +++ b/tools/fs_rm.sh @@ -14,7 +14,7 @@ main() { } _guard_path() { - path="$(realpath "$1")" + path="$(realpath -m "$1")" action="$2" if [[ ! "$path" == "$(pwd)"* ]]; then if [ -t 1 ]; then diff --git a/tools/fs_write.sh b/tools/fs_write.sh index 59ee812..b37a2d5 100755 --- a/tools/fs_write.sh +++ b/tools/fs_write.sh @@ -17,7 +17,7 @@ main() { } _guard_path() { - path="$(realpath "$1")" + path="$(realpath -m "$1")" action="$2" if [[ ! "$path" == "$(pwd)"* ]]; then if [ -t 1 ]; then |
