X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:references:to:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=xpyjuxt14NBbp+BU hXGqhEfcANCYlteYxrUyxH8ULLFTXFJNVNSSzSHetC3EIlj77WJMsklGoeKehH+F JeNHOkk4Ir/tcDxaCOucKh1I0tLqnsrYiSznPnUf69YhneMA9XuNjvXJQ5bzXuOJ omRvk96F0+Vg+rtXBLZKskwKHCs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:references:to:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=MAJCuxLTDS0GHJUfcyrxNq HUH/o=; b=cqIVed2SQRKWYYahZG9bYudTteY1aVuD//yyQ3C15HydzIqjt5lfHQ K8mdeJ3TwOY1owApNgNVjK/7lvT+v5LN0Xg6fFMphwFu//Mkd18PmHusLgEIzn3E 3nWAVakRTaSGIrE4Ful2kp+AfkjJH21s756KiHGzjVSEQ4JzsD4RE= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Michel, Hx-languages-length:1358, moss, Moss X-HELO: mailsrv.cs.umass.edu Reply-To: moss AT cs DOT umass DOT edu Subject: Re: alias appears to not work inside a called bash script References: <000001d31acd$108b0340$31a109c0$@rogers.com> To: cygwin AT cygwin DOT com From: Eliot Moss Message-ID: <071eb206-e739-ae88-a650-055c99cae046@cs.umass.edu> Date: Mon, 21 Aug 2017 18:53:52 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <000001d31acd$108b0340$31a109c0$@rogers.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes On 8/21/2017 6:30 PM, 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. From the bash man page: "Aliases are ot 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)." Could that be the root of your difficulty? Eliot Moss -- 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