Re: Spawning Unix commands from IDL under bash [message #93311 is a reply to message #93309] |
Sat, 11 June 2016 18:59  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Wow, bash turns out to be a lot more complicated than tcsh in this case.
Craig is correct (thanks!) that one creates a non-interactive shell when SPAWNing a bash command from IDL. But a non-interactive bash shell doesn't read .bashrc or .bash_profile or *any* file by default. Instead you have to set the environment variable BASH_ENV to point to the file with the alias commands.
But we are still not done because we need to tell bash to expand aliases. I have a vague idea why this is so, but I think my explanation would just come out as hand-waving. Anyway, one has to include the command
shopt -s expand_aliases
in the file containing the aliases.
Some of these tips come from the following post:
http://stackoverflow.com/questions/1615877/why-aliases-in-a- non-interactive-bash-shell-do-not-work
--Wayne
On Friday, June 10, 2016 at 2:30:12 PM UTC-4, Craig Markwardt wrote:
> On Friday, June 10, 2016 at 2:20:05 PM UTC-4, wlandsman wrote:
>> I've recently succumbed to peer pressure to switch my (Mac and Linux) shell from tcsh to bash.
>>
>> Everything is working fine except that I do not have access to the aliases defined in my .bash_profile (Mac) or .bashrc (linux) files when spawning from IDL. For example in my .bash_profile file I have
>>
>> alias ll="ls -l"
>>
>> I am able to use this alias at the system prompt but it is not recognized when spawning from the IDL prompt
>>
>> IDL> $ll (or IDL> spawn,'ll' )
>> bash: ll: command not found
>>
>> Note that this is not a PATH problem and IDL> spawn,'ls' does work.
>
> I think you are spawning an interactive non-login shell. See here...
>
> https://www.gnu.org/software/bash/manual/html_node/Bash-Star tup-Files.html
>
> So it may depend whether your alias is defined in .bashrc or .bash_profile.
>
> Craig
|
|
|