Shell function / alias for rails console / server, etc. For work with rails 2 and 3

Rails 3 introduced the rails {c,s,g} command format for invoking the console, server, generators, etc.

Back with rails 2 I had alias c=script/console , and others are configured to facilitate text input.

I would like to do the same for rails 3, but I still support rails 2 applications. Can I have an alias / function / of another shell that checks for the existence of script / foo and runs it if it is, otherwise run the rails 3 equivalents?

Sorry for the lazy question; bash / zsh scripting is designed to rot one imho brane, and I rather hope someone else can handle it.

+4
source share
1 answer

Use test -f

alias c="if [ -f script/console ]; then script/console; else script/rails console; fi"

+6
source

Source: https://habr.com/ru/post/1336001/


All Articles