delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/08/22/10:31:19

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:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; q=dns; s=default; b=b828IHd
eGakHseb4jZcyOBjfDQ2E9r29hAjA5C5Uf3Z2cqgQTUyUmwK0SwgESV9rrSvJ0pG
Zz3sxVEhSzswna+8yVs1DzvAOB/PE6U/YcFDJOCgW6sg0e5j9kZct+kgEaVTsBiz
lDvsP41/+CfvvdzlCZNokjLmzTEiS75Ow3y4=
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:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; s=default; bh=mDtWX6/Rxd/8w
gDf4o0o0lqZrlQ=; b=yVs2NiM03+dvq/IMgg7DvFWsvcSZ6uUYXKXuLCjX3l+rh
W/wG5h/ZYDR4Va5I8oYnJRIfcnZe0b/2S99QF6Z/yhhwEvXCmBacVzpy+D1800go
Lt1Tzmy1Cl8RFpzWafyy4HeSXMbb5fnoZaeXsi2gHkPommpw9VMSriiA3RJ7n0=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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=-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
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
In-Reply-To: <000001d31acd$108b0340$31a109c0$@rogers.com>
References: <000001d31acd$108b0340$31a109c0$@rogers.com>
From: Stephen John Smoogen <smooge AT gmail DOT com>
Date: Tue, 22 Aug 2017 10:31:02 -0400
Message-ID: <CANnLRdgWnygyp36uYmpzq7i3BvgHonL5H8CPy_Vr+wOYmWjp4w@mail.gmail.com>
Subject: Re: alias appears to not work inside a called bash script
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

On 21 August 2017 at 18:30, Michel LaBarre <michel DOT labarre AT rogers DOT 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019