소스 검색

Enable reloading modules

Useful for modules like pretty.sh so that they can benefit from safety and
simplicity of having default but app can still reload it.

Note that in most cases using sfpi is cleaner and does not need
reloading, but pretty.sh is using dumb way of loading.
Alois Mahdal 4 년 전
부모
커밋
e96616b77e
1개의 변경된 파일13개의 추가작업 그리고 0개의 파일을 삭제
  1. 13
    0
      src/shellfu.sh.skel

+ 13
- 0
src/shellfu.sh.skel 파일 보기

@@ -173,6 +173,19 @@ shellfu() {
173 173
                 shellfu __die "cannot import module: $mname"
174 174
             fi
175 175
             ;;
176
+        reload)
177
+            #
178
+            # Reload module named $1 (unsafe!)
179
+            #
180
+            local mname=$1
181
+            shellfu _is_imported "$mname" || {
182
+                shellfu __warn "cannot reload; not imported yet: $mname"
183
+                return 2
184
+            }
185
+            if ! shellfu _do_import "$mname"; then
186
+                shellfu __die "cannot reload module: $mname"
187
+            fi
188
+            ;;
176 189
         try_import)
177 190
             #
178 191
             # Try if module $1 could be imported