public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Michel LaBarre" <michel.labarre@rogers.com>
To: "'Duncan Roe'" <duncan_roe@optusnet.com.au>,	<cygwin@cygwin.com>,
	"'Eliot Moss'" <moss@cs.umass.edu>
Subject: RE: alias appears to not work inside a called bash scripty
Date: Tue, 22 Aug 2017 01:01:00 -0000	[thread overview]
Message-ID: <000d01d31ae2$12d70990$38851cb0$@rogers.com> (raw)
In-Reply-To: <20170821225531.GB3317@dimstar.local.net>

Rats!  You are right. Thank you so much Duncan and Eliot (both for the
information and the tactful tone :-)  ).

I will review shopt  - I had been only looking at "set" for relevant
options.


> -----Original Message-----
> From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com] On
> Behalf Of Duncan Roe
> Sent: August-21-17 6:56 PM
> To: cygwin@cygwin.com
> Subject: Re: alias appears to not work inside a called bash scripty
> 
> 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


--
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

  reply	other threads:[~2017-08-22  1:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 22:30 alias appears to not work inside a called bash script Michel LaBarre
2017-08-21 22:53 ` Eliot Moss
2017-08-21 22:55 ` alias appears to not work inside a called bash scripty Duncan Roe
2017-08-22  1:01   ` Michel LaBarre [this message]
2017-08-22 14:31 ` alias appears to not work inside a called bash script Stephen John Smoogen
2017-08-22 14:47   ` Eliot Moss
2017-08-22 15:19     ` Stephen John Smoogen
2017-08-22 16:46       ` Eliot Moss
2017-08-22 18:25         ` Stephen John Smoogen
2017-08-25  0:37           ` Either trim quoted text or STOP BOTTOM POSTING (was: alias appears to not work...) L A Walsh
2017-08-25 14:25             ` Either trim quoted text or STOP BOTTOM POSTING cyg Simple
2017-08-25 16:43               ` Dan Kegel
2017-08-26  6:04               ` convenient trimming of quoted text to make points L A Walsh
2017-08-26 15:26                 ` cyg Simple
2017-09-01  4:54                   ` Duncan Roe
2017-09-01  7:37                     ` Csaba Raduly
2017-09-01 12:38                       ` cyg Simple
2017-08-22 17:08       ` alias appears to not work inside a called bash script cyg Simple
2017-08-22 17:14         ` Eliot Moss
2017-08-22 19:07           ` cyg Simple
2017-08-22 19:11             ` cyg Simple
2017-08-23 19:08               ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000d01d31ae2$12d70990$38851cb0$@rogers.com' \
    --to=michel.labarre@rogers.com \
    --cc=cygwin@cygwin.com \
    --cc=duncan_roe@optusnet.com.au \
    --cc=moss@cs.umass.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).