sshkit icon indicating copy to clipboard operation
sshkit copied to clipboard

command_map for piped commands

Open davidosomething opened this issue 12 years ago • 5 comments

Given: The SSHKit (capistrano) command in question is: execute :curl, "-s", fetch(:composer_download_url), "|", :php

My PHP binary is in the following path and set so: SSHKit.config.command_map[:php] = '/usr/local/bin/php54'

Problem: The :curl symbol is correctly replaced from the command map, but the :php symbol is not.

I've tested replacement by changing the :curl value in the command_map and succeeded, so I'm guessing it's because :php is in a pipe or is the second substitution that it is not replaced?

davidosomething avatar Nov 14 '13 21:11 davidosomething

I've tested replacement by changing the :curl value in the command_map and succeeded, so I'm guessing it's because :php is in a pipe or is the second substitution that it is not replaced?

Only the first argument passed to _execute (which backs capture(), test(), execute(), etc) is mapped.

The string/symbol split is tricky, as what happens when someone would do:

execute :rake, :test

(which I often do), I want it expanded to (perhaps) /usr/bin/env rake test.

I'd consider a patch to make it map symbols regardless of their position, but you'd have to test it pretty thoroughly, and it'd mean a breaking change I think.

leehambley avatar Nov 15 '13 06:11 leehambley

Any news on this? Thank you!

cibulka avatar Sep 17 '15 07:09 cibulka

None, apparently the thread has been quiet for more than two years. What are you looking for?

leehambley avatar Sep 18 '15 07:09 leehambley

I have exactly the same problem as @davidosomething. My website is built on Wordpress and hosted on a shared host. For database import/export, I would like to use capistrano-wpcli gem.

As described on https://github.com/lavmeiker/capistrano-wpcli/issues/18, I have a problem with the following line:

execute :gunzip, "<", fetch(:wpcli_remote_db_file), "|", :wp, :db, :import, "-"

As you see, wp is not at the beginning of the command, so currently it is unaffected by setting SSHKit.config.command_map[:wp] = '~/wpcli.phar'.

Unfortunately the author of the gem is not replying to the issue and pull requests (this one would solve it), so it seems, that I'm in sort of a dead end on this. :)

Any thoughts?

cibulka avatar Sep 18 '15 09:09 cibulka

@cibulka Since we got life into the repo again i guess we will most likely have a solution for this one soon.

https://github.com/lavmeiker/capistrano-wpcli/issues/18

jeremyzahner avatar Sep 22 '15 19:09 jeremyzahner