penguin/utils

my env utils

commit 18bd009b35afdf2622b140a6bfbe03772712e32e

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-06-26T10:46:44Z
subjectForgot tho rebuild
commit 18bd009b35afdf2622b140a6bfbe03772712e32e
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-06-26T10:46:44Z

    Forgot tho rebuild
---
 bash/rbashrc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/bash/rbashrc b/bash/rbashrc
index 8ab284e..08d66bc 100755
--- a/bash/rbashrc
+++ b/bash/rbashrc
@@ -139,6 +139,16 @@ rbash_cache() {
   local url="$1"
   local key file
 
+  if [ -z "${RBASH_CACHE_DIR:-}" ]; then
+    echo "rbash: RBASH_CACHE_DIR is not set" >&2
+    return 1
+  fi
+
+  mkdir -p "$RBASH_CACHE_DIR" || {
+    echo "rbash: failed to create cache dir: $RBASH_CACHE_DIR" >&2
+    return 1
+  }
+
   if command -v md5sum >/dev/null 2>&1; then
     key="$(printf '%s' "$url" | md5sum | cut -d' ' -f1)"
   else
@@ -149,8 +159,10 @@ rbash_cache() {
 
   if [ ! -f "$file" ]; then
     rbash_download "$url" > "$file" || {
+      local rc=$?
       rm -f "$file"
-      return 1
+      echo "rbash: download failed: $url" >&2
+      return "$rc"
     }
     chmod 700 "$file"
   fi
@@ -234,6 +246,7 @@ rbash-run() {
   "$file" "$@"
 }
 
+
 # ---- rbash: bash/core/40_sources.bash ----
 
 rbash_sources_json_url() {