On 21 August 2017 at 18:30, Michel LaBarre <michel.laba...@rogers.com> 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 >
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 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 > > > > > -- > 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 -- Stephen J Smoogen. -- 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