I'm trying to make a "wrapper" bash alias function to evaluate mongo snippets
alias mongoshelleval=mongoshelleval
mongoshelleval(){
mongo --verbose --eval $1 $db
}
And I have the snippets stored as env variables
export delsessions='"db.sessions.drop()"'
The I execute the thing
mongoshelleval $delsessions
but it doesn't carry out the operation. It just
$ mongoshelleval $delsessions
MongoDB shell version: 2.4.8
Thu Aug 07 03:50:18.809 versionArrayTest passed
connecting to: db
Thu Aug 07 03:50:18.861 creating new connection to:127.0.0.1:27017
Thu Aug 07 03:50:18.867 BackgroundJob starting: ConnectBG
Thu Aug 07 03:50:18.870 connected connection!
db.sessions.drop()
Thu Aug 07 03:50:18.880 freeing 1 uncollected class mongo::DBClientWithCommands objects
Without throwing any errors. Just prints back the argument db.sessions.drop()
And the sessions are still there
$ mongoshell
MongoDB shell version: 2.4.8
connecting to: db
db.sessions.find()
{ "_id" : "yr5rxguSbb32Q880Jj36Rq2_uU
{ "_id" : "9PQh_ml5Gloiaunv6pbgVevM_6
{ "_id" : "OacGUyf-V1DcTQIg3lMgFXUL-N
{ "_id" : "GC7gh09iqVUny9HM8gnGl9Hzxt
{ "_id" : "_f4koE0tagJ7vwuU76BatcDeEb
{ "_id" : "t1CX_eqi7FcCREfBB2X5CpgOcz
Why doesn't it do what I intend it to do, and why isn't it throwing any errors if it's not carrying out the query?