homebrew-cask: Some non-existing stanzas do not error out with `_stanza`

Solution to be implemented

On brew cask _stanza {{whatever}} {{cask}}:

  1. Check if {{whatever}} is a valid stanza (in HBC as a whole). 1.1. If yes, continue to 2. 1.2. If no, print Warning/Error and immediately abort with exit code 1.

  2. Check if {{whatever}} exists in {{cask}}. 2.1. If yes, print it and exit code 0. 2.2. If no, print the Warning/Error and exit code 1.


Problem

On non-existing stanzas, _stanza correctly errors on some but not others. Will use ableton-live in the examples.

First, some stanzas the cask has:

$ brew cask _stanza version ableton-live
9.7.1
$ echo $?
0

$ brew cask _stanza name ableton-live
["Ableton Live"]
$ echo $?
0

Correct exit code, correct output.

Now, some stanzas the cask does not have. First exists (just not in the cask), the other is fake.

$ brew cask _stanza installer ableton-live
Warning: no such stanza 'installer' on Cask 'ableton-live'

Error: nothing to print
$ echo $?
1

$ brew cask _stanza fake_stanza ableton-live
Warning: no such stanza 'fake_stanza' on Cask 'ableton-live'

Error: nothing to print
$ echo $?
1

Correct exit code, correct output.

Some more stanzas the cask does not have. They all exist (just not in the cask).

$ brew cask _stanza appcast ableton-live

$ echo $?
0

$ brew cask _stanza gpg ableton-live

$ echo $?
0

Incorrect exit code, incorrect output (empty line, yes, but no error).

At first I thought it was misbehaving on optional stanzas, but then I tried preflight (which is optional).

$ brew cask _stanza preflight ableton-live
Warning: no such stanza 'preflight' on Cask 'ableton-live'

Error: nothing to print
$ echo $?
1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (21 by maintainers)

Most upvoted comments

Can we call that consensus?

Looks like we can!

Looks like deprecating both the multi-token and the all-token usage seems OK for everyone. Can we call that consensus?

Deprecating both would help get the current PR merged.

Option 3 it is. Will update the top post with it.

I also think more than one token would not work well, or be useful. No strong opinion on the “all” case though.

  • What artifacts are hosted on CloudFront? → brew cask _stanza url | grep cloudfront
  • Are there Casks that require an Adobe product? → brew cask _stanza depends_on | grep adobe

We could:

for cask in $(brew cask search); do
  brew cask _stanza url "${cask}"
done | grep cloudfront

and

for cask in $(brew cask search); do
  brew cask _stanza depends_on "${cask}"
done | grep adobe

Not as short and straightforward, but it’s not that much of a hassle and still works.

I’m not seeing good use cases for doing _stanza on multiple casks at once.

I do see the case for doing it sequentially and doing something with the result, for which we’d need a loop anyway.

I’m for the easiest solution: only allow one at a time, and if more than one (or none) are given, error out.

Option 3

On brew cask _stanza {{whatever}} {{cask}}:

  1. Check if {{whatever}} is a valid stanza (in HBC as a whole). 1.1. If yes, continue to 2. 1.2. If no, print Warning/Error and immediately abort with exit code 1.

  2. Check if {{whatever}} exists in {{cask}}. 2.1. If yes, print it and exit code 0. 2.2. If no, print the Warning/Error and exit code 1.

… which is basically the same as option 1 in terms of exit code, but differentiates between not in HBC and not in the Cask for the error message.