我希望在ZSH中动态地定义一系列函数。
例如:
然而,这会产生四个相同的函数,它们都调用最后一个参数:
有没有办法像这样动态定义这些函数呢?
例如:
#!/bin/zsh
for action in status start stop restart; do
$action() {
systemctl $action $*
}
done
然而,这会产生四个相同的函数,它们都调用最后一个参数:
$ status libvirtd
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to restart 'libvirtd.service'.
...
有没有办法像这样动态定义这些函数呢?