[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

zsh and ruby functions

d c

12/24/2007 10:01:00 AM

hi roobyfiends -

i am trying to get zshell to use some ruby scripts transparently but
running into problems.

in the ruby script i have:

#!/usr/bin/env ruby

and yet:
[dc@metroid:~]$ type svnbatchmove.rb (12-24 09:43)
svnbatchmove.rb is a shell function

then running of course gives parse errors:

[dc@metroid:~]$ svnbatchmove.rb (12-24 09:42)
svnbatchmove.rb:20: parse error near `puts'

how do i coerce zsh into recognizing this as ruby?

if i run the script directly (ie full path) it's fine...

i have this in my zshrc to prep the ruby scripts as zsh functions -
is there another way to do this? i tried adding this dir to my path,
but unable to find the new funcs.

autoload ~/rpm/bin/rubyfuncs/*(:t)

but this gives:

[dc@metroid:~]$ which svnbatchmove.rb (12-24 10:02)
svnbatchmove.rb () {
# undefined
builtin autoload -X
}

is it only possible to extend zsh with other shell algebra gook?

i found a workaround by defining a shell function to call the ruby one...

svnba() {
~dc/rpm/bin/shellfuncs/svnbatchmove.rb $*
}

but this is obviously duplicitious and duplicative ...

guess this maybe more of a zsh list thing but ... tips appreciated!

/dc

3 Answers

Dan Zwell

12/25/2007 12:46:00 AM

0

d c wrote:
> hi roobyfiends -
>
> i am trying to get zshell to use some ruby scripts transparently but
> running into problems.
>
> in the ruby script i have:
>
> #!/usr/bin/env ruby
>
> and yet:
> [dc@metroid:~]$ type svnbatchmove.rb (12-24 09:43)
> svnbatchmove.rb is a shell function
>
> then running of course gives parse errors:
>
> [dc@metroid:~]$ svnbatchmove.rb (12-24 09:42)
> svnbatchmove.rb:20: parse error near `puts'
>
> how do i coerce zsh into recognizing this as ruby?
>
> if i run the script directly (ie full path) it's fine...
>
> i have this in my zshrc to prep the ruby scripts as zsh functions -
> is there another way to do this? i tried adding this dir to my path,
> but unable to find the new funcs.
>
> autoload ~/rpm/bin/rubyfuncs/*(:t)
>
> but this gives:
>
> [dc@metroid:~]$ which svnbatchmove.rb (12-24 10:02)
> svnbatchmove.rb () {
> # undefined
> builtin autoload -X
> }
>
> is it only possible to extend zsh with other shell algebra gook?
>
> i found a workaround by defining a shell function to call the ruby one...
>
> svnba() {
> ~dc/rpm/bin/shellfuncs/svnbatchmove.rb $*
> }
>
> but this is obviously duplicitious and duplicative ...
>
> guess this maybe more of a zsh list thing but ... tips appreciated!
>
> /dc
>
>

Well, I've never used zsh, but you can just call "ruby
svnbatchmove.rb"--this will always work. If that's too clunky, you could
create a valid zsh script called "svnbatchmove" that acts as a wrapper
and calls "ruby svnbatchmove.rb".

Dan

Thomas Adam

12/25/2007 12:54:00 AM

0

Hello --

On 25/12/2007, Dan Zwell <dzwell@gmail.com> wrote:
> Well, I've never used zsh, but you can just call "ruby
> svnbatchmove.rb"--this will always work. If that's too clunky, you could
> create a valid zsh script called "svnbatchmove" that acts as a wrapper
> and calls "ruby svnbatchmove.rb".

This is what the "command" builtin is useful for.

-- Thomas Adam

Ben Lipton

12/25/2007 12:58:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

These are shots in the dark, as I haven't used zsh, but just maybe one of
them will be helpful:

1) Is the #! line the first line of the file?
2) Just for kicks, check if it works in another shell?
3) Hard-code the path to ruby rather than using /usr/bin/env to find it

On Dec 24, 2007 5:01 AM, d c <lister@pikkle.com> wrote:

> hi roobyfiends -
>
> i am trying to get zshell to use some ruby scripts transparently but
> running into problems.
>
> in the ruby script i have:
>
> #!/usr/bin/env ruby
>
> and yet:
> [dc@metroid:~]$ type svnbatchmove.rb (12-24
> 09:43)
> svnbatchmove.rb is a shell function
>
> then running of course gives parse errors:
>
> [dc@metroid:~]$ svnbatchmove.rb (12-24
> 09:42)
> svnbatchmove.rb:20: parse error near `puts'
>
> how do i coerce zsh into recognizing this as ruby?
>
> if i run the script directly (ie full path) it's fine...
>
> i have this in my zshrc to prep the ruby scripts as zsh functions -
> is there another way to do this? i tried adding this dir to my path,
> but unable to find the new funcs.
>
> autoload ~/rpm/bin/rubyfuncs/*(:t)
>
> but this gives:
>
> [dc@metroid:~]$ which svnbatchmove.rb (12-24
> 10:02)
> svnbatchmove.rb () {
> # undefined
> builtin autoload -X
> }
>
> is it only possible to extend zsh with other shell algebra gook?
>
> i found a workaround by defining a shell function to call the ruby one...
>
> svnba() {
> ~dc/rpm/bin/shellfuncs/svnbatchmove.rb $*
> }
>
> but this is obviously duplicitious and duplicative ...
>
> guess this maybe more of a zsh list thing but ... tips appreciated!
>
> /dc
>
>