comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Spawning Unix commands from IDL under bash
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Spawning Unix commands from IDL under bash [message #93311 is a reply to message #93309] Sat, 11 June 2016 18:59 Go to previous message
wlandsman is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: no text on new graphics - missing path or bad file?
Next Topic: Multi plots conditions

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:43:59 PDT 2025

Total time taken to generate the page: 0.00392 seconds