tenseleyflow/gump / 1d3a347

Browse files

fix: use [ ] for file tests and drop cd -- in fortsh generator

Authored by espadonne
SHA
1d3a347c763ec39c3d5cf5c82174321fec511783
Parents
6c5c8fe
Tree
cff921b

1 changed file

StatusFile+-
M src/cmd/init.rs 8 8
src/cmd/init.rsmodified
@@ -412,8 +412,8 @@ __gump_pwd_hook() {
412412
         command cd ~ && __gump_hook
413413
     elif [[ $# -eq 1 && "$1" == "-" ]]; then
414414
         command cd - && __gump_hook
415
-    elif [[ $# -eq 1 && -d "$1" ]]; then
416
-        command cd -- "$1" && __gump_hook
415
+    elif [ $# -eq 1 ] && [ -d "$1" ]; then
416
+        command cd "$1" && __gump_hook
417417
     else
418418
         local result
419419
         result=$(command gump query --cwd -- "$@" 2>/dev/null)
@@ -421,7 +421,7 @@ __gump_pwd_hook() {
421421
             result=$(command gump query -- "$@" 2>/dev/null)
422422
         fi
423423
         if [[ -n "$result" ]]; then
424
-            command cd -- "$result" && __gump_hook
424
+            command cd "$result" && __gump_hook
425425
         else
426426
             echo "gump: no match found" >&2
427427
             return 1
@@ -434,7 +434,7 @@ __gump_pwd_hook() {
434434
     local result
435435
     result=$(command gump query --all -- "$@" | fzf --height=40% --reverse)
436436
     if [[ -n "$result" ]]; then
437
-        command cd -- "$result" && __gump_hook
437
+        command cd "$result" && __gump_hook
438438
     fi
439439
 }}
440440
 "#,
@@ -447,8 +447,8 @@ __gump_pwd_hook() {
447447
 # No-prefix directory jumping
448448
 command_not_found_handle() {
449449
     # Check if it's a local directory first (exact match)
450
-    if [[ -d "$1" ]]; then
451
-        command cd -- "$1" && __gump_hook
450
+    if [ -d "$1" ]; then
451
+        command cd "$1" && __gump_hook
452452
         return 0
453453
     fi
454454
 
@@ -456,14 +456,14 @@ command_not_found_handle() {
456456
     local result
457457
     result=$(command gump query --cwd -- "$@" 2>/dev/null)
458458
     if [[ -n "$result" ]]; then
459
-        command cd -- "$result" && __gump_hook
459
+        command cd "$result" && __gump_hook
460460
         return 0
461461
     fi
462462
 
463463
     # Query gump database
464464
     result=$(command gump query -- "$@" 2>/dev/null)
465465
     if [[ -n "$result" ]]; then
466
-        command cd -- "$result" && __gump_hook
466
+        command cd "$result" && __gump_hook
467467
         return 0
468468
     fi
469469