Expand aliases in non-interactive shells

In bashwe can use shopt -s expand_aliasesto extend aliases in scripts.

What are the equivalent commands for zsh, cshand tcsh? Do they even exist?

Having focused my efforts on zsh, I did not find such a team. I even tried to find the file with aliases inside the script, but that didn't work.

+4
source share
1 answer

For zshyou can usesetopt aliases

#!/usr/bin/zsh

alias hoo="echo bar"
unsetopt aliases
hoo # outputs `./test.zsh:5: command not found: hoo`
setopt aliases
hoo # outputs `bar`

See more details man zshoptions.

For cshand it is tcshenough to find files ( source ${HOME}/.cshrcfor example).

+6
source

Source: https://habr.com/ru/post/1537811/


All Articles