How do you run pushd and popd using backticks?
Whenever I run pushd /tmp in backticks I get an error:
"No such file or directory - pushd /tmp"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ruby shell-outs (backticks) each run in a new subshell, so it doesn’t work perhaps in the way that you are thinking:
Also, are you sure
pushdworks in your shell? Maybe look at using ruby’ssystemorpopen3if you want something more useful than the backtick syntax.Dir#chdiraccepts a block. Here’s an example from the docs if all you need is to run some commands in a directory then change back: