Why does a #!/bin/bash script handle aliasing worse than a #!/bin/sh script?
A stripped-down example script that demonstrates the behavior that's befuddling me:
returns "bar: command not found", which is what I expect that script to return. On the other hand,
returns "foo: command not found", as if the alias command was ignored.
If anything, I'd expect the /bin/sh version of the script to ignore the alias, for possible compatibility with old scripts written for a version of /bin/sh that wasn't just a link to bash.
Could someone explain this behavior to me, please? It happens on more than one Linux distro, and even on Cygwin's bash under Windows (where /bin/sh is a copy of /bin/bash, not a symbolic link to it).
(who will just start his script with #!/bin/sh in the meantime)
Is there any bash Version Compatibility
I do found the same problem.:cool:
Is there any Version Compatibility;)
Either upgrade the version of bash or run configure under another shell
(such as /bin/sh).
Other suggestion of using function is good, as maual says;)
"For almost every purpose, shell functions are preferred over aliases. "