qrush / sub

a delicious way to organize programs
http://37signals.com/svn/posts/3264-automating-with-convention-introducing-sub
MIT License
1.74k stars 148 forks source link

eval "$(sub init -)" in .bash_profile throws errors #13

Closed Nattle closed 11 years ago

Nattle commented 11 years ago

When I add the proper line from sub init to my bash_profile it spews the following error: -bash: eval: line 31: syntax error near unexpected token )' -bash: eval: line 31: )'

This is definitely coming from the sub call. I also tried this format instead, but get the same error. subb=sub init - eval "$subb"

I can manually call this sequence and it will not produce the same error. sub init- > foo; eval < foo; rm foo

This is all on OSX, in case that is relevant.

mislav commented 11 years ago

It would be useful to paste your output of sub init - here so we can see what bash tries to eval and fails.

sub init - | pbcopy
# then paste to GitHub
Nattle commented 11 years ago
~/kiva/streams/kiva $ kiva init -

export PATH="${PATH}:/Users/mwaxler/kiva/streams/kiva/bin"
source "/Users/mwaxler/kiva/streams/kiva/libexec/../completions/kiva.bash"
kiva() {
  local command="$1"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  )
    eval `kiva "sh-$command" "$@"`;;
  *)
    command kiva "$command" "$@";;
  esac
}
mislav commented 11 years ago

You should edit your comment and wrap all code between triple tilde (~) signs at beginning and end. This transforms it into code block.

Nattle commented 11 years ago

Any idea what is going on here?

qrush commented 11 years ago

It looks like somehow the shell after the case statement got removed. Can you add it back in? Here's the output of sub init - from inside of the sub dir for me:

export PATH="${PATH}:/Users/qrush/dev/sub/bin"
source "/Users/qrush/dev/sub/libexec/../completions/sub.zsh"
sub() {
  local command="$1"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  shell)
    eval `sub "sh-$command" "$@"`;;
  *)
    command sub "$command" "$@";;
  esac
}
Nattle commented 11 years ago

Yes, that fixed it. Thanks so much for the assistance. I have no idea how that got broken, going back in my source control I dont see it ever being present. I'm going to chalk it up to a stray keystroke at some point.

Thanks again.