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 scripty


Rats!  You are right. Thank you so much Duncan and Eliot (both for the
information and the tactful tone :-)  ).

I will review shopt  - I had been only looking at "set" for relevant
options.


> -----Original Message-----
> From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com] On
> Behalf Of Duncan Roe
> Sent: August-21-17 6:56 PM
> To: cygwin@cygwin.com
> Subject: Re: alias appears to not work inside a called bash scripty
> 
> On Mon, Aug 21, 2017 at 06:30:15PM -0400, Michel LaBarre wrote:
> > Hello all,
> >
> > I have a 4 line bash script:
> >   #!/bin/bash
> >   alias nawk=gawk
> >   alias nawk
> >   nawk  'BEGIN {FS="^"} ; (length($0) > maxline) { maxline = length($0)
;
> > line=$0} ; END{print maxline, line}' $*
> >
> >
> > When I run the script I see:
> >   alias nawk='gawk'
> >  /cygdrive/c/mybin/maxline/: line 4: nawk: command not found
> >
> > It looks like the alias is properly defined but it does not appear to
take
> > effect.
> >
> > Same thing happens if I alias to awk instead of qawk.
> >
> > Same thing happens if I define the alias in .bashrc (I include an echo
in
> > bashrc to confirm that it is being invoked).
> >
> > My .bashrc is not likely a factor - I empty it and the result is the
same.
> > No carriage returns in the script or .bashrc.
> >
> > I have updated everything August 5th using setup and letting all
"Pending"
> > pkgs update so I believe I am up to date.
> >
> > The funny thing is that it works ok from an interactive session, whether
the
> > alias is explicitly defined in the session or in .bashrc.
> >
> > Thank you in advance for any insights.
> >
> > BTW - I just re-subscribed to cygwin 4-5 hours ago and have not seen any
> > mail which seems unusual based on past experience.
> >
> > Michel LaBarre
> > 613-692-0507
> >
> >
> This is expected behaviour. "man bash" gibes
> 
> " Aliases are not expanded when the shell is not interactive, unless the
> expand_aliases shell option is set using shopt (see the description of
shopt
> under SHELL BUILTIN COMMANDS below).
> 
> Cheers ... Duncan.
> 
> --
> 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


--
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]