I have some global aliases defined in my ~/.profile file. To read them from a bash script, I'd use:

shopt -s expand_aliases
source ~/.profile

However, in ksh this does not work because it does not have a shopt command. How do I read the aliases from a file in ksh?

  • Do you need to do something special in ksh? It seems, the alias are expanded in non-interactive shells, too. – mpy Jan 4 '14 at 12:22
  • Yes, I'm using ksh because I have a for loop in the script and I need to call variables from that loop, bash does not support this. – shrx Jan 4 '14 at 14:25
  • Uh, sorry, that was a missunderstanding. I did a quick test with a #!/bin/ksh script, therein sourced an alias file and used an alias with no problem. So my question was, do you need a shopt equivalent after all? Or: What does not work? – mpy Jan 4 '14 at 17:49
  • Have you figured it out? – PSkocik Jul 1 '17 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.