delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/08/21/18:55:49

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:date:from:to:subject:message-id:references
:mime-version:content-type:in-reply-to; q=dns; s=default; b=BS3Z
N8UNefaV3F8R5hv9UB+7E9WM0TbLt2ydecidzCqs+t9t6uVG4MYTjRwimbCmvsXT
8Vfxt3DNBfOhdPZvah4gbt9v0admFr9ZOXM3iA1xrQDDB1N70MSOMvZeHCjne8f8
Y3p0sE2fGRB/j5YOZKncW2+EoYJ4KlRazuWCxTA=
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:date:from:to:subject:message-id:references
:mime-version:content-type:in-reply-to; s=default; bh=ZGwYa6UWgN
KQ42Srq7NVEoYZyWc=; b=GIiGSgEQoWz3SSH+2SjMApKRQNaHI617jAXw+C4xUS
bV+BeBN6/il8sK3RQcnbtyxfZ1tEX8fdLhgYVB+QDXEdATgXI/CskP9v1mVoeYRF
R3NW8HEbkpeEQlKrkYba1vl8nJa/0jgEbRL+y4DiKYDqRaJfNK/87Fjm8O3EzoIm
I=
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.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
Date: Tue, 22 Aug 2017 08:55:31 +1000
From: Duncan Roe <duncan_roe AT optusnet DOT com DOT au>
To: cygwin AT cygwin DOT com
Subject: Re: alias appears to not work inside a called bash scripty
Message-ID: <20170821225531.GB3317@dimstar.local.net>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <000001d31acd$108b0340$31a109c0$@rogers.com>
MIME-Version: 1.0
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

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

- Raw text -


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