The biggest thing I miss in shell scripts over Ruby is exceptions. I like my apps to crash quickly if something goes wrong (unless I explicitly rescue it), rather than try to continue blindly like shell scripts do by default.
Worst case example: cd /dir/with/a/typo rm -rf # don't try this at home One thing I'd really, really, really like in your tool is to have each line abort the script (or some similar exception mechanism) on failure. On Jan 21, 10:05 pm, Ezra Zygmuntowicz <[EMAIL PROTECTED]> wrote: > Hey Folks- > > I spent the weekend working on a shell script builder DSL for > writing your capistrano tasks in ruby instead of putting shell script > snippets in strings to the run method. > > I wrote about this on my blog with a call for some input on look and > feel and whatnot. > > http://brainspl.at/articles/2007/01/22/shellscriptbuilder-for-capistranohttp://brainspl.at/shell_script_builder.tar.gz > > Right now it is just a standalone library that generates shell > scripts. I haven't made the mechanism that will allow cap to upload > these scripts to the servers and execute them but thats an easy task. > I am going to try to rewrite all the standard cap recipes to use this > Builder instead of shell scripts. > > The reasoning is that with this dsl you will not have to remember > what all the flags to bash's if statements are. And you also don';t > have to worry about shell escaping or the way capistrano escapes > commands itself. > > I would love some feedback and thoughts from folks as to whether > they would use this or not. > > Here is a small example: > > script = shell do |sh| > sh.sudo.ln_nsf "foo/bar", "bar/bar" > > sh.echo "some string" => "/path/to/log.txt" > > sh.if :directory? => "some/dir" do |sub| > sub.rm_rf 'some/dir' > sub.ln_nsf "shared/foo", "some/dir" > sub.if_not :file? => 'foo' do |ssub| > ssub.mkdir_p "some/foo" > end > end > > sh.unless :file? => 'foo/bario' do |sub| > sub.touch 'foo/bario' > end > > sh.if :writable? => "some/file.txt" do |sub| > sub.echo "#{Time.now}" => 'some/file.txt' > end > sh.mkdir_p 'foo/bar' > sh.rm_rf 'foo/bar' > end > > puts script > OUTPUT: > > #!/bin/sh > sudo ln -nsf foo/bar bar/bar > echo "some string" >> /path/to/log.txt > if [ -d some/dir ] > then > rm -rf some/dir > ln -nsf shared/foo some/dir > if [ ! -a foo ] > then > mkdir -p some/foo > fi > fi > if [ ! -a foo/bario ] > then > touch foo/bario > fi > if [ -w some/file.txt ] > then > echo "#{time}" >> some/file.txt > fi > mkdir -p foo/bar > rm -rf foo/bar > > Cheers- > -- Ezra Zygmuntowicz > -- Lead Rails Evangelist > -- [EMAIL PROTECTED] > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/capistrano -~----------~----~----~----~------~----~------~--~---
