我想在脚本中执行“别名”命令。它位于用户的“设置”区域下。我可以执行“env”,但希望随后使用他们/我将通过“别名”命令看到的设置别名。有办法吗?我试过:
if [[ "${command}" == "L" || "${command}" == "l" ]]
then
echo " "
echo "Environment settings (env): "
env
echo " "
echo "aliases: "
`/bin/bash;alias`
`alias`
`echo ${BASH_ALIASES[]}`
/bin/bash;alias
alias
echo ${BASH_ALIASES[]}
echo " "
echo "Done with Settings. Hit Enter to continue. "
read settings_trash
fi
但我总是得不到任何结果/null 或者一个新的 shell。
答案1
你需要一个交互式外壳查看别名。
下面的示例bash
可能可以帮助你修复脚本
bash -c 'alias' # does not see any alias
bash -ic 'alias' # sees a lot of aliases (in my system)