alias appears to not work inside a called bash script

Michel LaBarre michel.labarre@rogers.com
Mon Aug 21 22:30:00 GMT 2017


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 36535 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20170821/2b4896ae/attachment.obj>
-------------- next part --------------

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


More information about the Cygwin mailing list