mirror of
https://github.com/mickael-menu/zk
synced 2024-11-07 15:20:21 +00:00
Prevent recursive aliases
This commit is contained in:
parent
9f0b5dc7d4
commit
e12d7cca42
6
main.go
6
main.go
@ -106,12 +106,16 @@ func indexZk(container *cmd.Container) {
|
||||
|
||||
// runAlias will execute a user alias if the command is one of them.
|
||||
func runAlias(container *cmd.Container, args []string) (bool, error) {
|
||||
runningAlias := os.Getenv("ZK_RUNNING_ALIAS")
|
||||
if zk, err := container.OpenZk(); err == nil && len(args) >= 1 {
|
||||
for alias, cmdStr := range zk.Config.Aliases {
|
||||
if alias != args[0] {
|
||||
if alias == runningAlias || alias != args[0] {
|
||||
continue
|
||||
}
|
||||
|
||||
// Prevent infinite loop if an alias calls itself.
|
||||
os.Setenv("ZK_RUNNING_ALIAS", alias)
|
||||
|
||||
cmd := executil.CommandFromString(cmdStr, args[1:]...)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
|
Loading…
Reference in New Issue
Block a user