alias appears to not work inside a called bash script

Kaz Kylheku 920-082-4242@kylheku.com
Tue Aug 22 19:47:00 GMT 2017


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?

There is an issue there (though not for the Cygwin project).

I don't see where this behavior is required in POSIX: that is,
expanding aliases in interactive mode, but ignoring them in 
non-interactive
operation.

POSIX seems to unequivocally be calling for Alias Expansion to occur
under all conditions.

And, indeed, this is not a bug in Bash; they know that this is
a POSIX deviation. Because, voila, aliases *are* expanded in
script mode if we do one of two things:

    #!/bin/bash --posix

    #!/bin/sh

Bash in POSIX mode knows every well that it had better
expand aliases regardless of non-interactive operation.

However, *suppressing* a useful behavior in a default, non-standard
mode is highly counter-intuitive.

I mean we can't even call this a vendor *extension* with a straight
face. What do we call this? "retraction?" :)

"To disable the vendor-specific retraction that aliases don't
work, operate bash in POSIX mode, or use the expand_aliases
shopt."

:)


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



More information about the Cygwin mailing list