Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Failed to use alias command in bash script

Hi,

I'm writing a bash script using alias command. It's normal when I enable alias options with "shopt -s expand_aliases" and put all the code in one file. However, if the script is divided into 2, confusing situation happens.

Below is part of the code to demonstrate the problem. Please help. Thanks.


sub script(sub.sh):

subFunction(){

alias ll="ls -l"

alias -p <= normal here

ll <= command not found

}


main script(main.sh):

source sub.sh

shopt -s expand_aliases

subFunction

ll <= normal here

iMac, macOS High Sierra (10.13), null

Posted on Oct 10, 2018 1:34 AM

Reply
1 reply

Failed to use alias command in bash script

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.