{"action":"created","issue":{"url":"https://api.github.com/repos/capistrano/sshkit/issues/270","labels_url":"https://api.github.com/repos/capistrano/sshkit/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/capistrano/sshkit/issues/270/comments","events_url":"https://api.github.com/repos/capistrano/sshkit/issues/270/events","html_url":"https://github.com/capistrano/sshkit/issues/270","id":99569122,"number":270,"title":"Export environment","user":{"login":"kuon","id":160200,"avatar_url":"https://avatars.githubusercontent.com/u/160200?v=3","gravatar_id":"","url":"https://api.github.com/users/kuon","html_url":"https://github.com/kuon","followers_url":"https://api.github.com/users/kuon/followers","following_url":"https://api.github.com/users/kuon/following{/other_user}","gists_url":"https://api.github.com/users/kuon/gists{/gist_id}","starred_url":"https://api.github.com/users/kuon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuon/subscriptions","organizations_url":"https://api.github.com/users/kuon/orgs","repos_url":"https://api.github.com/users/kuon/repos","events_url":"https://api.github.com/users/kuon/events{/privacy}","received_events_url":"https://api.github.com/users/kuon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-07T03:16:42Z","updated_at":"2015-08-10T09:36:03Z","closed_at":null,"body":"Here:\r\n\r\nhttps://github.com/capistrano/sshkit/blob/32c04ed1cae3608468c3888a727eff54c8bd34fd/lib/sshkit/command.rb#L166\r\n\r\nExporting the environment;\r\n\r\n```ruby\r\n\"( export #{environment_string}; %s )\" % yield\r\n```\r\n\r\nWould allow for variable substitution in commands, like so:\r\n\r\n```\r\nexecute(:psql, '-d $DATABASE_URL')\r\n```\r\n\r\nActually the \"effect\" is because of the `;` I added before the command, but this requires to export the environment string to allow it's use in subsequent commands.\r\n\r\nThis would also allow more flexible prefixes.\r\n\r\nFor example:\r\n\r\n```\r\nSSHKit.config.command_map.prefix[:ruby].unshift('some shell script;')\r\n```\r\n\r\n\r\nto have ruby being executed this way:\r\n\r\n```\r\nsome shell script; ruby\r\n```\r\n\r\nOf course, this is already possible, but the command loses the access to the env var because they are not exported.\r\n"},"comment":{"url":"https://api.github.com/repos/capistrano/sshkit/issues/comments/129381710","html_url":"https://github.com/capistrano/sshkit/issues/270#issuecomment-129381710","issue_url":"https://api.github.com/repos/capistrano/sshkit/issues/270","id":129381710,"user":{"login":"leehambley","id":18952,"avatar_url":"https://avatars.githubusercontent.com/u/18952?v=3","gravatar_id":"","url":"https://api.github.com/users/leehambley","html_url":"https://github.com/leehambley","followers_url":"https://api.github.com/users/leehambley/followers","following_url":"https://api.github.com/users/leehambley/following{/other_user}","gists_url":"https://api.github.com/users/leehambley/gists{/gist_id}","starred_url":"https://api.github.com/users/leehambley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leehambley/subscriptions","organizations_url":"https://api.github.com/users/leehambley/orgs","repos_url":"https://api.github.com/users/leehambley/repos","events_url":"https://api.github.com/users/leehambley/events{/privacy}","received_events_url":"https://api.github.com/users/leehambley/received_events","type":"User","site_admin":false},"created_at":"2015-08-10T09:36:03Z","updated_at":"2015-08-10T09:36:03Z","body":"Would you care to prepare a PR and add yourself to the CHANGELOG, etc, I think this is a fair change."}}