Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Formula/g/granted.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class Granted < Formula
def install
ldflags = "-s -w -X github.com/common-fate/granted/internal/build.Version=#{version}"
system "go", "build", *std_go_args(ldflags:), "./cmd/granted"

# Install shell wrapper scripts
bin.install "scripts/assume"
bin.install "scripts/assume.fish"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bin.install "scripts/assume.fish"

bash script alone should be enough, i see no reason to have another script that does the same thing but with .fish extension

Copy link
Author

@chrnorm chrnorm Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is required because Granted supports the fish shell (https://docs.commonfate.io/granted/configuration#fish). It is a different script to assume. The regular assume shell script is incompatible with fish, so we need to also include this file with the .fish extension.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding -- during normal use these scripts get sourced into the shell, not executed, so the script doesn't control its interpreter. The script needs to be natively compatible with the shell.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they need to be sourced instead of executed, why write them to bin?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use granted, and also support fish users using granted. The change above mirrors how granted was installed previously:

https://github.com/common-fate/homebrew-granted/blob/6bef334c52370f99931864c66e66a472798d05ff/Formula/granted.rb

Can't speak to why both of these are written to bin, but this does match how the granted authors intended this package to be installed.

Copy link
Member

@SMillerDev SMillerDev Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is this:
If we put it in bin, will users be expecting that. Or can we make it easier somehow?
If it needs to be sourced, we can put it in a directory that automatically gets sourced. That seems more user friendly to me.

If it just needs to be in PATH when granted is executed, maybe we can make a wrapper script that does that.
But it's still unclear to me how/if users are expected to interact with assume

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrnorm could you help clarify here? What are users expecting? Are they expecting to call assume? Or are they expecting assume to be sourced when they open their shell?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is called by users. However, the first time that Granted runs, it installs an alias in users' shell profile (such as ~/.bashrc), for example:

alias assume="source (brew --prefix)/bin/assume.fish"

so when they call assume they are sourcing the script. The script is not sourced automatically when users open their shell, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so it's only ever called once by users. Because afterwards it will run the alias instead when people do assume. So what if we just make bin/assume a script that sources some/path/assume?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrnorm That hardcoded path isn't critical, since we can inreplace it at build. In the event we want to throw it into libexec or something that's what we'd do.


# Create assumego symlink
bin.install_symlink "granted" => "assumego"
end

test do
Expand Down
Loading