Re: alias appears to not work inside a called bash script

2017-08-24 Thread L A Walsh
Kaz Kylheku wrote: There is an issue there (though not for the Cygwin project). I don't see where ... "expanding aliases in interactive mode, but ignoring them in non-interactive operation" [is required by POSIX]. POSIX seems to unequivocally be calling for Alias Expansion to occur under al

Re: alias appears to not work inside a called bash script

2017-08-23 Thread Eric Blake
On 08/22/2017 02:11 PM, cyg Simple wrote: > > And --enable-strict-posix-default configure option turns this setting on > by default. I'll leave it up to the Cygwin maintainer to decide if it > should be used. It should not. It will break more things than it fixes (running bash as /bin/sh alread

Re: alias appears to not work inside a called bash script

2017-08-22 Thread Kaz Kylheku
On 21.08.2017 15:53, Eliot Moss wrote: 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?

Re: alias appears to not work inside a called bash script

2017-08-22 Thread cyg Simple
On 8/22/2017 3:07 PM, cyg Simple wrote: > On 8/22/2017 1:13 PM, Eliot Moss wrote: >> On 8/22/2017 1:07 PM, cyg Simple wrote: >>> On 8/22/2017 11:18 AM, Stephen John Smoogen wrote: On 22 August 2017 at 10:47, Eliot Moss wrote: > On 8/22/2017 10:31 AM, Stephen John Smoogen wrote: >> >>> Are

Re: alias appears to not work inside a called bash script

2017-08-22 Thread cyg Simple
On 8/22/2017 1:13 PM, Eliot Moss wrote: > On 8/22/2017 1:07 PM, cyg Simple wrote: >> On 8/22/2017 11:18 AM, Stephen John Smoogen wrote: >>> On 22 August 2017 at 10:47, Eliot Moss wrote: On 8/22/2017 10:31 AM, Stephen John Smoogen wrote: > >> Are you talking bash as sh or bash as bash?  Bash

Re: alias appears to not work inside a called bash script

2017-08-22 Thread Stephen John Smoogen
On 22 August 2017 at 12:45, Eliot Moss wrote: > On 8/22/2017 11:18 AM, Stephen John Smoogen wrote: >> >> On 22 August 2017 at 10:47, Eliot Moss wrote: >>> >>> On 8/22/2017 10:31 AM, Stephen John Smoogen wrote: > > >>> It's a *bash* default - it has nothing to do with Cygwin as distinct >>> from o

Re: alias appears to not work inside a called bash script

2017-08-22 Thread Eliot Moss
On 8/22/2017 1:07 PM, cyg Simple wrote: On 8/22/2017 11:18 AM, Stephen John Smoogen wrote: On 22 August 2017 at 10:47, Eliot Moss wrote: On 8/22/2017 10:31 AM, Stephen John Smoogen wrote: Are you talking bash as sh or bash as bash? Bash as sh will expand those aliases. But you should stud

Re: alias appears to not work inside a called bash script

2017-08-22 Thread cyg Simple
On 8/22/2017 11:18 AM, Stephen John Smoogen wrote: > On 22 August 2017 at 10:47, Eliot Moss wrote: >> On 8/22/2017 10:31 AM, Stephen John Smoogen wrote: >> >>> 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

Re: alias appears to not work inside a called bash script

2017-08-22 Thread Eliot Moss
On 8/22/2017 11:18 AM, Stephen John Smoogen wrote: On 22 August 2017 at 10:47, Eliot Moss wrote: On 8/22/2017 10:31 AM, Stephen John Smoogen wrote: It's a *bash* default - it has nothing to do with Cygwin as distinct from other bash installations. If you had a different experience elsewhere

Re: alias appears to not work inside a called bash script

2017-08-22 Thread Stephen John Smoogen
On 22 August 2017 at 10:47, Eliot Moss wrote: > On 8/22/2017 10:31 AM, Stephen John Smoogen wrote: > >> 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

Re: alias appears to not work inside a called bash script

2017-08-22 Thread Eliot Moss
On 8/22/2017 10:31 AM, Stephen John Smoogen wrote: 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

Re: alias appears to not work inside a called bash script

2017-08-22 Thread Stephen John Smoogen
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 s

Re: alias appears to not work inside a called bash script

2017-08-21 Thread Eliot Moss
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 appears to not work inside a called bash script

2017-08-21 Thread Michel LaBarre
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: comm