It's documented *somewhere*, I recall having written about why, the long
and short version is "anything with a whitespace in it is not safe for us
to modify, and prepend and append paths, commands, etc", that unfortunately
also applies to test(), and of course there is no `test(:some, :symbol)`
syntax that makes sense.

I'd suggest to use the `capture()` api to `capture(:pwd)`, and use Ruby's
`File.join()` APIs (or, just concatenate the strings) to build the command
to test for.

If you do happen to stumble on the docs, I'd be happy to have an
improvement PR to make it more visible, as when I wrote it, and even I
can't find it is a bad sign :(

Lee Hambley
http://lee.hambley.name/
+49 (0) 170 298 5667

On 26 February 2015 at 15:46, ruud <r.grosm...@gmail.com> wrote:

> Versions:
>
>    - Ruby 2.0.0
>    - Capistrano 3.3.5
>
> Platform:
>
>    - debian wheezy.
>
> hello group,
>
> I encountered an unexpected feature of capistrano. When I test a file or
> directory with 'if test [ -d .....]', in a within block, the directory of
> that test is based on the working directory instead of the directory in the
> within block.
>
> Who can explain what happens?
>
> The following Capfile illustrates this; the second task is the most
> readable, but does not work as I expect. The first, in which the file test
> is done outside the within block, is a working version of it. Has this
> anything to do with the ssh toolkit? Can I use the second task by adjusting
> the used syntax?
>
>
> require 'capistrano/setup'
> require 'capistrano/deploy'
>
> namespace :rbg do
>     desc 'check git directory'
>     task :check_gitdir do
>         on roles :installatie, :test do
>             if test ( "[ -d "  + fetch( :deploy_to) + "/.git ]" )
>                 info " git-dir exists"
>             else
>                 info " git-dir does not exist"
>                 within deploy_to do
>                     execute :git, 'init'
>                 end
>             end
>         end
>     end
>
>     task :check_gitdir_doesn_work do
>         on roles :installatie, :test do
>             within deploy_to do
>                 if test "[ -d .git ]"
>                     info " git-dir exists"
>                 else
>                     info " git-dir does not exist"
>                     execute :git, 'init'
>                 end
>             end
>         end
>     end
> end
>
> Output of task 1 (correct) when applying this on a host with a .git
> directory within the deploy directory:
>
> INFO git-dir exists
>
> Output of task 2 in the same situation:
>
> INFO git-dir does not exist
> INFO [e64c94b6] Running /usr/bin/env git init as dep...@172.xx.xx.xx
> INFO [e64c94b6] Finished in 0.238 seconds with exit status 0 (successful).
> INFO [b45c3b5b] Running /usr/bin/env git remote add repo REPOSITORYNAME as
> .......
>
> Thanks in advance for helping me understanding what is going on.
>
> Ruud
>
> --
> You received this message because you are subscribed to the Google Groups
> "Capistrano" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to capistrano+unsubscr...@googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/capistrano/8d2bab9b-3355-43c3-be15-66a3e0606324%40googlegroups.com
> <https://groups.google.com/d/msgid/capistrano/8d2bab9b-3355-43c3-be15-66a3e0606324%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capistrano+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/capistrano/CAN_%2BVLW3z2Juh1_YU7xx4TmoVRRzq31DJB%2B0PGdBnDcUVo8R4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to