antigen icon indicating copy to clipboard operation
antigen copied to clipboard

`antigen update` not working inside script

Open jackcogdill opened this issue 6 years ago • 3 comments

Description

TL;DR, unixorn/autoupdate-antigen.zshplugin does not seem to be working.

Steps to reproduce

Minimal steps to reproduce this behavior:

1 - `antigen bundle unixorn/autoupdate-antigen.zshplugin`

Expected behavior:

Should auto update once a week and produce some output like this:

Updating mafredri/zsh-async@master... Done. Took 0s.
Updating robbyrussell/oh-my-zsh@master... Done. Took 1s.
Updating sindresorhus/pure@master... Done. Took 0s.
Updating zsh-users/zsh-autosuggestions@master... Done. Took 1s.
Updating zsh-users/zsh-syntax-highlighting@master... Done. Took 1s.

Current behavior:

Never outputs anything.

Software version

  • antigen version Antigen develop (d1dd78b) Revision date: 2018-01-15 14:37:21 -0300
  • zsh --version zsh 5.5.1 (x86_64-debian-linux-gnu)
  • uname -a Linux (can't disclose)

Configuration

  • gist of .zshrc
source ~/.antigen/antigen.zsh
antigen use oh-my-zsh

# Plugins
antigen bundle git
antigen bundle sudo
antigen bundle history
antigen bundle extract
antigen bundle debian

antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle unixorn/autoupdate-antigen.zshplugin # Auto updates for antigen

# Theme
antigen bundle mafredri/zsh-async
antigen bundle sindresorhus/pure

antigen apply

More information

I went through the hassle of forking and rewriting the auto update plugin here.

After some debugging, it seems that everything in the plugin should work, except running antigen update or antigen selfupdate finishes instantly with no output.

I ran which antigen inside the script and it produced this output:

antigen () {
        local MATCH MBEGIN MEND
        [[ "$ZSH_EVAL_CONTEXT" =~ "toplevel:*" || "$ZSH_EVAL_CONTEXT" =~ "cmdarg:*" ]] && source "/my/usr/path/.antigen/antigen.zsh" && eval antigen $@
        return 0
}

It appears that [[ "$ZSH_EVAL_CONTEXT" =~ "toplevel:*" || "$ZSH_EVAL_CONTEXT" =~ "cmdarg:*" ]] evaluates to false. My question is, is this intended behavior for scripts? Why can we not use antigen update inside of a plugin?

jackcogdill avatar Jul 09 '19 17:07 jackcogdill

Hi @jackcogdill,

have you found a solution to this problem? I would also like to call antigen update from a script of mine which executes update functions of several applications like Homebrew, SDKMAN, etc.

The following snippet inside a ZSH shell script doesn't do anything...

source /usr/local/share/antigen/antigen.zsh
antigen update

svenjacobs avatar Jun 16 '21 06:06 svenjacobs

@svenjacobs I switched to using zplug since it seemed all around better.

jackcogdill avatar Jun 17 '21 17:06 jackcogdill