This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: alias appears to not work inside a called bash script


On 8/22/2017 11:18 AM, Stephen John Smoogen wrote:
> On 22 August 2017 at 10:47, Eliot Moss <moss@cs.umass.edu> wrote:
>> On 8/22/2017 10:31 AM, Stephen John Smoogen wrote:
>>
>>> I replicated this problem on my system and found that the fix is to add a
>>>
>>> shopt -s expand_aliases
>>>
>>> at the top of the script. I don't know why the option is turned off
>>> when running scripts versus in a plain script but that seems to be a
>>> default in Cygwin.
>>
>>
>> It's a *bash* default - it has nothing to do with Cygwin as distinct
>> from other bash installations.  If you had a different experience
>> elsewhere, it could be that the default was overridden in some system
>> wide bashrc file - but that strikes me as unlikely.  I suspect that
>> this is done as a security measure, to prevent an alias from introducing
>> a surprise.
>>
> 
> I checked on CentOS and there is no shopt option set in any of the
> /etc/ files. It must be a compiled in default of some sort as EL6 and
> EL7 both work without an explicit `shopt -s expand_aliases`. I then
> tried on an Ubuntu 16.04 system and it works without the `shopt -s
> expand_aliases` also.
> 
> I didn't have access to anything else at the moment so I can't say
> which other systems might actually follow the default other than
> Cygwin at the moment.

Are you talking bash as sh or bash as bash?  Bash as sh will expand
those aliases.  But you should study
http://tldp.org/LDP/abs/html/aliases.html for all your scripts.  Are
there environment variables that could affect the outcome?

-- 
cyg Simple

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]