From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50913 invoked by alias); 21 Aug 2017 22:55:37 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 50904 invoked by uid 89); 21 Aug 2017 22:55:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Michel, Hx-languages-length:1574, H*F:D*au, H*F:D*com.au X-HELO: mail108.syd.optusnet.com.au Received: from mail108.syd.optusnet.com.au (HELO mail108.syd.optusnet.com.au) (211.29.132.59) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Aug 2017 22:55:35 +0000 Received: from dimstar.local.net (c110-22-56-26.eburwd6.vic.optusnet.com.au [110.22.56.26]) by mail108.syd.optusnet.com.au (Postfix) with SMTP id 387C61A67C8 for ; Tue, 22 Aug 2017 08:55:32 +1000 (AEST) Received: (qmail 3978 invoked by uid 501); 21 Aug 2017 22:55:31 -0000 Date: Mon, 21 Aug 2017 22:55:00 -0000 From: Duncan Roe To: cygwin@cygwin.com Subject: Re: alias appears to not work inside a called bash scripty Message-ID: <20170821225531.GB3317@dimstar.local.net> Mail-Followup-To: cygwin@cygwin.com References: <000001d31acd$108b0340$31a109c0$@rogers.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000001d31acd$108b0340$31a109c0$@rogers.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=LI0WeNe9 c=1 sm=1 tr=0 a=/xIuaNGu1NPzt0yKkvdCVQ==:117 a=/xIuaNGu1NPzt0yKkvdCVQ==:17 a=kj9zAlcOel0A:10 a=KeKAF7QvOSUA:10 a=7-0_f1qKVzzfiYbRBtIA:9 a=MsLjMpgi9041_ghl:21 a=X_fX_Zsdn1PS_bfL:21 a=CjuIK1q_8ugA:10 a=HSQRNLQLWWwA:10 X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00190.txt.bz2 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