I use zsh in centos. And I want running some shell script. Like this.script.sh#!/bin/sh# something ..source ./aliases-file.shaliases-file.shalias test=lsalias test2=catI run ./script.sh, the alias has not been applied to the current session.how can I work this?
run bash script doesn't work alias command in zsh
bash;shell;scripting;alias
When you run script.sh it is executed in a subshell and your aliases won't propagate up to the calling shell (or current session as you refer to it). You need to source script.sh itself: source script.sh. That will cause the commands to be run in your current shell and the aliases will become visible.Side note: for portability reasons you should consider using . instead of source as the former is POSIX standard while the latter is a bashism.