Bash aliases not recognized by bash: sunspot_rails, jruby, rspec

Aliases below for using the sunspot in the background Aliases below for searching and killing these cases work ENV variables are available for the sunspot ports But, Functions for starting sunspots, processing the command and killing the spots only work after I leave .bashrc outside functions.

$ user_id is set before this sunspot_ports () is called and prints correctly the first time you log in to rebash - this is an alias for the source ~ .bashrc

I have aliases for development and production - this is just representative code.

sunspot_ports ()
{  
  #alias sunspot_run_test to the user port
  sunspot_test_port=$(($user_id +5300))
  echo "Your sunspot test port: $sunspot_test_port"
  alias sunspot_run_test="RAILS_ENV=test sunspot-solr run -p${sunspot_test_port} &"
  alias sunspot_kill_test="fuser -n tcp ${sunspot_test_port} -k"

  export sunspot_production_port sunspot_development_port sunspot_test_port
}

solr_test()
{
  #only makes the aliases be recognized when it is outside the function
  #rebash
  #aliases not recognized without a rebash prior to the function 
  sunspot_run_test
  #commands not recognized even with rebash
  #"RAILS_ENV=test sunspot-solr run -p${sunspot_test_port} &"
  sleep 10;
  "$@";
  sunspot_kill_test;
  #commands not recognized even with rebash
  #"fuser -n tcp ${sunspot_test_port} -k"
}

.bashrc , sunspot_ports() . , , .

, .bashrc, - jruby-, jvm forking ( sunspot-solr start sunspot-solr end )

+1
1

bash , , . (sunspot_ports), solr_test.

:

  • sunspot_ports solr_test
  • , ,
sunspot_kill_test()
{
   user -n tcp ${sunspot_test_port} -k
}
+1

All Articles