From 14411cb904b7682fe2a5c69861bfffa96f124707 Mon Sep 17 00:00:00 2001 From: Paul Gideon Dann Date: Mon, 19 Sep 2011 12:40:29 +0100 Subject: [PATCH] Tweaks to the wakeonlan plugin These were suggested by sorin-ionescu in pull request #343. --- plugins/wakeonlan/wakeonlan.plugin.zsh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/wakeonlan/wakeonlan.plugin.zsh b/plugins/wakeonlan/wakeonlan.plugin.zsh index 08db1bdea..752bfc600 100644 --- a/plugins/wakeonlan/wakeonlan.plugin.zsh +++ b/plugins/wakeonlan/wakeonlan.plugin.zsh @@ -1,15 +1,18 @@ function wake() { - local config_file=~/.wakeonlan/$1 - if [[ ! -f $config_file ]]; then + local config_file="$HOME/.wakeonlan/$1" + if [[ ! -f "$config_file" ]]; then echo "ERROR: There is no configuration file at \"$config_file\"." - return + return 1 fi - which wakeonlan > /dev/null - if [[ ! $? == 0 ]]; then + if (( ! $+commands[wakeonlan] )); then echo "ERROR: Can't find \"wakeonlan\". Are you sure it's installed?" - return + return 1 fi wakeonlan -f $config_file } + +if (( $+functions[compdef] )); then + compdef "_arguments '1:device to wake:_files -W '\''$HOME/.wakeonlan'\'''" wake +fi