Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This seems like it should be easy enough to do, but I'm clearly not understanding something fundamental about piping output back and forth.

I'm trying to do something like this:

bundle show some-gem-name | pushd

Where the result puts me in the path of the gem name with popd functionality supported to get back where I was.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

pushd expects the directory as a command line argument, not as standard input so you cannot pipe the directory to it. Try

pushd "`bundle show some-gem-name`"

instead.

share|improve this answer
5  
Alternative: pushd "$(bundle show some-gem-name)" - works identical, but could be easier to type depending on the keyboard layout. $(...) can be used nested. –  jofel Mar 26 '12 at 15:52
1  
@jofel The difference is more than that. See unix.stackexchange.com/q/5778/9382 –  rozcietrzewiacz Mar 26 '12 at 17:09
1  
@rozcietrzewiacz Actually in this case there is no difference. backticks and $(…) only differ when there are backslashes or backticks inside. –  Gilles Mar 26 '12 at 22:54
    
@Gilles OK, thanks for pointing that out. To make it clear: I referred to jofel's comment on ease of typing - which shouldn't be seen as the only difference in general (when someone reads this slightly out of context). –  rozcietrzewiacz Mar 26 '12 at 23:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.