autojump-22.2.4-fix-autojump.fish-bugs.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From f09d23e30d3159db18872a3e8f8f579ed9e77231 Mon Sep 17 00:00:00 2001
  2. From: David Frascone <David.Frascone@dishdigital.com>
  3. Date: Tue, 9 Jun 2015 14:32:38 -0600
  4. Subject: [PATCH] Fixed some bugs in fish script
  5. OSTYPE was not being set correctly. It is in bash, not sh.
  6. Since the value is unlikely to change, I read it once and
  7. stored it globally
  8. Test logic was backward in jo function, causing error to always
  9. be printed, unless you did NOT specify a directory name.
  10. ---
  11. bin/autojump.fish | 20 ++++++++++++--------
  12. 1 file changed, 12 insertions(+), 8 deletions(-)
  13. diff --git a/bin/autojump.fish b/bin/autojump.fish
  14. index 2cf5001..19cb27e 100644
  15. --- a/bin/autojump.fish
  16. +++ b/bin/autojump.fish
  17. @@ -5,6 +5,11 @@ if test -d ~/.autojump
  18. set -x PATH ~/.autojump/bin $PATH
  19. end
  20. +# Set ostype, if not set
  21. +if not set -q OSTYPE
  22. + set -gx OSTYPE (bash -c 'echo ${OSTYPE}')
  23. +end
  24. +
  25. # enable tab completion
  26. complete -x -c j -a '(autojump --complete (commandline -t))'
  27. @@ -34,7 +39,7 @@ end
  28. # misc helper functions
  29. function __aj_err
  30. # TODO(ting|#247): set error file location
  31. - echo $argv 1>&2; false
  32. + echo -e $argv 1>&2; false
  33. end
  34. # default autojump command
  35. @@ -73,11 +78,7 @@ end
  36. function jo
  37. set -l output (autojump $argv)
  38. if test -d "$output"
  39. - __aj_err "autojump: directory '"$argv"' not found"
  40. - __aj_err "\n$output\n"
  41. - __aj_err "Try `autojump --help` for more information."
  42. - else
  43. - switch (sh -c 'echo ${OSTYPE}')
  44. + switch $OSTYPE
  45. case 'linux*'
  46. xdg-open (autojump $argv)
  47. case 'darwin*'
  48. @@ -85,9 +86,12 @@ function jo
  49. case cygwin
  50. cygstart "" (cygpath -w -a (pwd))
  51. case '*'
  52. - __aj_error "Unknown operating system: '"$OSTYPE"'"
  53. + __aj_error "Unknown operating system: \"$OSTYPE\""
  54. end
  55. - echo end
  56. + else
  57. + __aj_err "autojump: directory '"$argv"' not found"
  58. + __aj_err "\n$output\n"
  59. + __aj_err "Try `autojump --help` for more information."
  60. end
  61. end