PDA

View Full Version : [ubuntu] .bashrc not sourced when running bash script from unity dash



heyneman
November 5th, 2011, 08:53 PM
I just upgraded to 11.10 and decided to try out using Unity for a while, instead of the classic menu. I have a few programs that need to be run with variables set in my .bashrc, and previously I was able to create a bash script to run the program and point a launcher at that script to make sure the program ran with all the right env variables (as per https://help.ubuntu.com/community/HowToAddaLauncher). It worked perfectly with the classic menu.

However, if I use Unity Dash to find and run the launcher (which runs the script) my .bashrc is apparently not sourced. If I run the script directly from a terminal everything is fine (as expected), but if I run it from nautilus I have the same problem. The script is simply:

#!/bin/bash
spyder

I've tested exporting env variables directly in the script, and explicitly sourcing either ~/.bashrc or the relevant files that .bashrc sources. Everything works except explictly sourcing ~/.bashrc.

Anyone else run into this or similar issues (and hopefully know how to fix them)?

heyneman
November 6th, 2011, 07:28 AM
Well, I solved my own problem, so hopefully this is helpful to someone else. Apparently the shell invoked is non-interactive, so ~/.bashrc isn't sourced. I don't remember having to do this before, so maybe something has changed the type of shell invoked? (I'm really not sure).

But in any case, to fix it all I had to do was start the script off with:

#!/bin/bash -i

Hope that helps someone else out there...