Skip to content

Instantly share code, notes, and snippets.

@robhurring
Forked from dholdren/broken_cd.sh
Created October 31, 2014 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robhurring/c59f30e37d9550a8878f to your computer and use it in GitHub Desktop.
Save robhurring/c59f30e37d9550a8878f to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e # works without this
set -x # debug
source "$HOME/.rvm/scripts/rvm" #so 'cd' will change gemset when dotfiles present
#setup
rm -rf ~/tmp/dir_with_gemfile
mkdir -p ~/tmp/dir_with_gemfile
echo "source 'https://rubygems.org'" > ~/tmp/dir_with_gemfile/Gemfile
echo "gem 'rails'" >> ~/tmp/dir_with_gemfile/Gemfile
#end setup
#works
echo 'pre cd ~'
cd ~
echo 'post cd ~'
#exits after "cd"
echo 'pre cd ~/tmp/dir_with_gemfile'
cd ~/tmp/dir_with_gemfile
echo 'post cd ~/tmp/dir_with_gemfile'
>./broken_cd.sh
pre cd ~
post cd ~
pre cd ~/tmp/dir_with_gemfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment