Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

shell-init broken for both bash and zsh in 0.8.0 #537

Closed
grimm26 opened this issue Sep 28, 2015 · 5 comments
Closed

shell-init broken for both bash and zsh in 0.8.0 #537

grimm26 opened this issue Sep 28, 2015 · 5 comments

Comments

@grimm26
Copy link

grimm26 commented Sep 28, 2015

% echo $SHELL
/opt/local/bin/zsh
% echo $ZSH_VERSION
5.0.5
 % eval $(/opt/chefdk/bin/chef shell-init zsh)
zsh: parse error near `then'
%
...
bash-4.3$ echo $BASH_VERSION
4.3.42(1)-release
bash-4.3$ eval $(/opt/chefdk/bin/chef shell-init bash)
bash: syntax error near unexpected token `('
bash-4.3$
@danielsdeleo
Copy link
Contributor

What is it actually printing? Perhaps there's some warning that's getting printed to the stdout stream or something? This works for me on zsh 5.0.5 and bash 3.2.57(1)-release

@grimm26
Copy link
Author

grimm26 commented Sep 28, 2015

% /opt/chefdk/bin/chef shell-init zsh
export PATH="/opt/chefdk/bin:/Users/mkeisler/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/embedded/bin:/Users/mkeisler/bin:/Users/mkeisler/packer:/Users/mkeisler/.gem/ruby/2.2.2/bin:/Users/mkeisler/.rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/bin:/Users/mkeisler/.rubies/ruby-2.2.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/opt/local/bin:/opt/local/sbin"
export GEM_ROOT="/opt/chefdk/embedded/lib/ruby/gems/2.1.0"
export GEM_HOME="/Users/mkeisler/.chefdk/gem/ruby/2.1.0"
export GEM_PATH="/Users/mkeisler/.chefdk/gem/ruby/2.1.0:/opt/chefdk/embedded/lib/ruby/gems/2.1.0"
function _chef() {

  local -a _1st_arguments
  _1st_arguments=(
      'exec:Runs the command in context of the embedded ruby'
      'env:Prints environment variables used by ChefDK'
      'gem:Runs the `gem` command in context of the embedded ruby'
      'generate:Generate a new app, cookbook, or component'
      'shell-init:Initialize your shell to use ChefDK as your primary ruby'
      'install:Install cookbooks from a Policyfile and generate a locked cookbook set'
      'update:Updates a Policyfile.lock.json with latest run_list and cookbooks'
      'push:Push a local policy lock to a policy group on the server'
      'push-archive:Push a policy archive to a policy group on the server'
      'show-policy:Show policyfile objects on you Chef Server'
      'diff:Generate an itemized diff of two Policyfile lock documents'
      'provision:Provision VMs and clusters via cookbook'
      'export:Export a policy lock as a Chef Zero code repo'
      'clean-policy-revisions:Delete unused policy revisions on the server'
      'clean-policy-cookbooks:Delete unused policyfile cookbooks on the server'
      'delete-policy-group:Delete a policy group on the server'
      'delete-policy:Delete all revisions of a policy on the server'
      'undelete:Undo a delete command'
      'verify:Test the embedded ChefDK applications'
    )

  _arguments \
    '(-v --version)'{-v,--version}'[version information]' \
    '*:: :->subcmds' && return 0

  if (( CURRENT == 1 )); then
    _describe -t commands "chef subcommand" _1st_arguments
    return
  fi
}

compdef _chef chef
% /opt/chefdk/bin/chef shell-init bash
export PATH="/opt/chefdk/bin:/Users/mkeisler/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/embedded/bin:/Users/mkeisler/bin:/Users/mkeisler/packer:/Users/mkeisler/.gem/ruby/2.2.2/bin:/Users/mkeisler/.rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/bin:/Users/mkeisler/.rubies/ruby-2.2.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/opt/local/bin:/opt/local/sbin"
export GEM_ROOT="/opt/chefdk/embedded/lib/ruby/gems/2.1.0"
export GEM_HOME="/Users/mkeisler/.chefdk/gem/ruby/2.1.0"
export GEM_PATH="/Users/mkeisler/.chefdk/gem/ruby/2.1.0:/opt/chefdk/embedded/lib/ruby/gems/2.1.0"
_chef_comp() {
    local COMMANDS="exec env gem generate shell-init install update push push-archive show-policy diff provision export clean-policy-revisions clean-policy-cookbooks delete-policy-group delete-policy undelete verify"
    COMPREPLY=($(compgen -W "$COMMANDS" -- ${COMP_WORDS[COMP_CWORD]} ))
}
complete -F _chef_comp chef

@grimm26
Copy link
Author

grimm26 commented Sep 28, 2015

This seems to get rid of the zsh error:

--- chef_orig.zsh       2015-09-28 12:38:52.000000000 -0500
+++ chef.zsh    2015-09-28 12:35:03.000000000 -0500
@@ -31,7 +31,7 @@
     '(-v --version)'{-v,--version}'[version information]' \
     '*:: :->subcmds' && return 0

-  if (( CURRENT == 1 )); then
+  if [ (( CURRENT == 1 )) ]; then
     _describe -t commands "chef subcommand" _1st_arguments
     return
   fi

@danielsdeleo
Copy link
Contributor

You need quotes around the eval'd string for it to work correctly, as shown in the chef shell-init -h output, i.e. do eval "$(chef shell-init SHELL_NAME)" and don't do eval $(chef shell-init SHELL_NAME)

@grimm26
Copy link
Author

grimm26 commented Sep 28, 2015

doh. didn't need that for 0.7.0

ksubrama pushed a commit that referenced this issue Jan 11, 2016
Add `inspec` and `kitchen-inspec` to ChefDK
@chef-boneyard chef-boneyard locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants