diff options
| -rwxr-xr-x | tools/fs_write.sh | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/fs_write.sh b/tools/fs_write.sh index 303a77b..e418835 100755 --- a/tools/fs_write.sh +++ b/tools/fs_write.sh @@ -11,8 +11,13 @@ set -e ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" main() { - "$ROOT_DIR/utils/guard_path.sh" "$argc_path" "Write '$argc_path'?" - mkdir -p "$(dirname "$argc_path")" + if [[ -f "$argc_path" ]]; then + printf "%s" "$argc_contents" | git diff --no-index "$argc_path" - || true + "$ROOT_DIR/utils/guard_operation.sh" "Apply changes?" + else + "$ROOT_DIR/utils/guard_path.sh" "$argc_path" "Write '$argc_path'?" + mkdir -p "$(dirname "$argc_path")" + fi printf "%s" "$argc_contents" > "$argc_path" echo "The contents written to: $argc_path" >> "$LLM_OUTPUT" } |
