Closed Frieshansen closed 5 years ago
Wowowow...there are so many quotes and double quotes I neither can read the command :D This should be a command escape problem and a great case study. On my schedule.
Thanks for the report.
Hi @Frieshansen ,
I've published a pre-release but yet to test it in real world. You can install and use it by gem install wordmove --pre
. Your feedback is really important to us.
I'm committed to to a final release as soon as we'll have tested this one together.
Thanks in advance
Ref: 102f27930aa35bf7d10ccf7cb0cd11bb3c5bb10b
Feels like it needs more work, but waiting for feedback anyway
With 3.2.3pre
I get the this output (same config as in the first post):
▬▬ Running local hooks ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
local | Exec command: sed -i "s/'dev_state' => '.*/'dev_state' => 'local',/" config.php
local | Output:
✅ success |
▬▬ Running remote hooks ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
remote | Exec command: sed -i "s/'dev_state' => '.*/'dev_state' => 'stage',/" config.php
remote | Output: bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file
❌ error | Error code 1
There now seems to be a problem with spaces also:
remote:
- 'touch testfile'
outputs this:
remote | Output: bash: touch testfile: command not found
❌ error | Error code 127
This happens only in 3.2.3pre
- in 3.2.2
the above config is working.
Hey @Frieshansen thank you very much. My bad. I'll iterate with a pre2 version as of today - I think. I already have an idea about coding approach and another behavioural one.
I'm committed to fix this ASAP because hooks are getting everyday more important to us and, I think, to the whole community.
I'm on a path, but it's a bit more complex and I need a little more thinking.
I've updated the pre-release. The point here is that in order to remove escaping I've also introduced a support constraint: on remote side a bash-like shell is required, since I no more enforce the use of bash through bash -l -c
command.
The "auto-cd" feature relies on cd WPROOT &&
concatenated w/ the hook's command. But e.g.: fish shell has a different syntax than &&
combining commands.
I hope this is a good tradeoff atm.
I'm testing successfully with there remote hooks:
hooks:
pull:
before:
remote:
- 'touch testfile'
- "echo \"hi ' there\" > testfile"
- 'cat testfile'
- "sed -i \"s/hi ' there/hello there/\" testfile"
- 'cat testfile'
obtaining
▬▬ Running remote hooks ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
remote | Exec command: touch testfile
remote | Output:
✅ success |
remote | Exec command: echo "hi ' there" > testfile
remote | Output:
✅ success |
remote | Exec command: cat testfile
remote | Output: hi ' there
✅ success |
remote | Exec command: sed -i "s/hi ' there/hello there/" testfile
remote | Output:
✅ success |
remote | Exec command: cat testfile
remote | Output: hello there
✅ success |
Waiting for your feedback @Frieshansen
Best
@pioneerskies thanks for the update. It´s now working as expected (by me) with bash as remote shell.
Unfortunately I´ve no good idea to support shells with different concat-syntax other than checking and running a case-expression for them. Perhaps you could also use ; to concat the commands (which would work in fish) but then you have to check the existance of the directory first.
Finally 3.2.3 is out :)
I´m trying to remotely execute the command
sed -i "s/'dev_state' => '.*/'dev_state' => 'stage',/" config.php
. This is how the config looks:And this is the output from wordmove:
The command is running without problems directly on the remote machine and the working directory is also the right one.