From da6814a4858180e15a773b9cb1fc5db5aa315320 Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Sun, 15 Mar 2026 15:04:17 +0900 Subject: [PATCH 1/4] Don't use global variables --- src/_cask | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_cask b/src/_cask index 3cd4335..fe4276f 100644 --- a/src/_cask +++ b/src/_cask @@ -48,7 +48,7 @@ function _cask() { case $state in subcommand) - subcommands=( + local -a subcommands=( "build:build all Elisp files in the files directive" "clean-elc:remove all byte compiled Elisp files in the files directive" "exec:execute command with correct 'exec-path' and 'load-path'" From 0dce3a833b3059b4e97961cc27624d4f817ea665 Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Sun, 15 Mar 2026 15:07:47 +0900 Subject: [PATCH 2/4] Don't overwrite context variables --- src/_cask | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/_cask b/src/_cask index fe4276f..89c4e73 100644 --- a/src/_cask +++ b/src/_cask @@ -41,8 +41,11 @@ # ------------------------------------------------------------------------------ function _cask() { - local ret=1 state - _arguments \ + typeset -A opt_args + local context state line ret=1 + local curcontext="$curcontext" + + _arguments -C \ ':subcommand:->subcommand' \ '*:: :->subcmds' && ret=0 From 96316552eafcb902d5185297e812d0705a78b485 Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Sun, 15 Mar 2026 15:08:37 +0900 Subject: [PATCH 3/4] Merge two switch-case --- src/_cask | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/_cask b/src/_cask index 89c4e73..13102a0 100644 --- a/src/_cask +++ b/src/_cask @@ -50,7 +50,7 @@ function _cask() { '*:: :->subcmds' && ret=0 case $state in - subcommand) + (subcommand) local -a subcommands=( "build:build all Elisp files in the files directive" "clean-elc:remove all byte compiled Elisp files in the files directive" @@ -74,15 +74,20 @@ function _cask() { "upgrade:upgrade Cask itself and its dependencies" "version:print program version" ) - _describe -t subcommands 'cask subcommands' subcommands && ret=0 - esac - case "$words[1]" in - init) - _arguments \ - '(--dev)--dev[Run in dev mode]' && ret=0 ;; - exec) - _generic + _describe -t subcommands 'cask subcommands' subcommands && ret=0 + ;; + (subcmds) + case "$words[1]" in + (init) + _arguments \ + '(--dev)--dev[Run in dev mode]' \ + && ret=0 + ;; + (exec) + _generic + ;; + esac ;; esac From d1180f126ada59543335b1802f7dc819b797b8fc Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Sun, 15 Mar 2026 15:14:40 +0900 Subject: [PATCH 4/4] Add global options --- src/_cask | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/_cask b/src/_cask index 13102a0..ff06771 100644 --- a/src/_cask +++ b/src/_cask @@ -46,8 +46,20 @@ function _cask() { local curcontext="$curcontext" _arguments -C \ + '(--proxy --http-proxy --https-proxy)--proxy[Set emacs proxy for HTTPS and HTTPS]:host:_hosts' \ + '(--proxy --http-proxy)--http-proxy[Set emacs proxy for HTTP]:host:_hosts' \ + '(--proxy --https-proxy)--https-proxy[Set emacs proxy for HTTPS]:host:_hosts' \ + '(--proxy --http-proxy --https-proxy)--proxy[Set emacs proxy for HTTPS and HTTPS]:host:_hosts' \ + '--no-proxy[Set Emacs no-proxy to HOST]:host:_hosts' \ + '(- *)--version[Print Cask version and exit]' \ + '(- *)'{-h,--help}'[Display usage or information for command]::command:->subcommand' \ + '--debug[Turn on debug output]' \ + '--path[Run command in this PATH instead of default-directory]:dir:_files -/' \ + '(--verbose --silent)--verbose[Be verbose and show debug output]' \ + '(--verbose --silent)--verbose[Be slient and do not show anything]' \ ':subcommand:->subcommand' \ - '*:: :->subcmds' && ret=0 + '*:: :->subcmds' \ + && ret=0 case $state in (subcommand)