在非交互式shell中展开别名

use*_*369 5 csh zsh tcsh

bash,我们可以shopt -s expand_aliases用来扩展脚本中的别名.

什么是等价的命令zsh,cshtcsh?他们甚至存在吗?

在集中精力的同时zsh,我还没有找到这样的命令.我甚至尝试使用脚本中的别名来获取文件,但它没有用.

ymo*_*nad 9

对于zsh您可以使用setopt aliases

#!/usr/bin/zsh

alias hoo="echo bar"
unsetopt aliases
hoo # outputs `./test.zsh:5: command not found: hoo`
setopt aliases
hoo # outputs `bar`
Run Code Online (Sandbox Code Playgroud)

man zshoptions详细.

对于cshtcsh,采购文件(source ${HOME}/.cshrc例如)就足够了.