Checking if a ruby gem is installed from bash script
I need to, from a bash script, check to see if certain Ruby gems are installed .
I thought I could do something like
if ! gem list <name>; then do_stuff; fi
but testing on the command line using echo $? shows that gem list <name> returns 0 regardless of if name is actually found.
Does this mean I have to use grep to filter the output of gem list, or is there a better way I can check to see if a gem is installed?
gem list <name> -i will return the string true if the gem is installed and false otherwise. Also, the return codes are what you would expect.
For more informations, see gem help list.
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





