From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68427 invoked by alias); 22 Aug 2017 14:31:07 -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 68403 invoked by uid 89); 22 Aug 2017 14:31:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-qk0-f179.google.com Received: from mail-qk0-f179.google.com (HELO mail-qk0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Aug 2017 14:31:05 +0000 Received: by mail-qk0-f179.google.com with SMTP id o63so33135585qkb.3 for ; Tue, 22 Aug 2017 07:31:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=ISX81dT19Y0lW9aR3iLd8wHwAaBh8EV81Q0TPJNUWxw=; b=miSbw8zSz1Sc5vgWGXq2AZY2mdJU/JlTcSRKKxTwzbhsk2LcqHU1HmQrEqwob33WKw Hn+36NhGj0unnqSMZwUClwr2kiwYptsnvIECYFaXwnvf4eN0HXi3bG5K/UrwbSsqGgNO OML9cYLlafrN4WWdxMEgLUl1GetrlUMViCdoj8vySq76rSzWimuLJ0eIS2Lo8hRu8N2+ t6gWxomTRxjwH+PeQqYzzAcrr82q4OtBs8cREJIhueFh0Csr+ayk/P3yPQiKltzdmpom WFkjCsx0fpGG21/j4P+/1Xl8ckkAVXtkaiX97BrjpegCgpBDH+XPAtGyKPF+bpj9Do0x HURw== X-Gm-Message-State: AHYfb5hv0S0SFqp+bFFZd5d7/Zij1zgwLa/NnM9PZ7fdda3anKqdK8Lq o3JawB9p9fuHThyZA7qny8MUbuQ6rUt8 X-Received: by 10.55.156.13 with SMTP id f13mr1272753qke.141.1503412263533; Tue, 22 Aug 2017 07:31:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.95.46 with HTTP; Tue, 22 Aug 2017 07:31:02 -0700 (PDT) In-Reply-To: <000001d31acd$108b0340$31a109c0$@rogers.com> References: <000001d31acd$108b0340$31a109c0$@rogers.com> From: Stephen John Smoogen Date: Tue, 22 Aug 2017 14:31:00 -0000 Message-ID: Subject: Re: alias appears to not work inside a called bash script To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00194.txt.bz2 On 21 August 2017 at 18:30, 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 > 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