Skip to content

Commit

Permalink
Don't skip processing for internal commands always. (#172)
Browse files Browse the repository at this point in the history
We can only do this when they are in the first couple positions. Otherwise this becomes problematic once they get passed into a subcommand+subcommand where a nil Conn == panic.
  • Loading branch information
sfc-gh-jchacon authored Oct 17, 2022
1 parent 6e1e71d commit 19f7e07
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/sanssh/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,16 @@ func (p *prefixWriter) Write(b []byte) (n int, err error) {
// As this is intended to be called from main() it doesn't return errors and will instead exit on any errors.
func Run(ctx context.Context, rs RunState) {
// If we're running internal commands we don't need anything else.
for _, f := range flag.Args() {
for i, f := range flag.Args() {
switch f {
case "help", "flags", "commands":
os.Exit(int(subcommands.Execute(ctx, &util.ExecuteState{})))
// Only do this if it's in the first couple positions.
// Otherwise we end up doing - sanssh service enable help
// which then tries to actually run the enable command without
// a conn and blows up.
if i < 2 {
os.Exit(int(subcommands.Execute(ctx, &util.ExecuteState{})))
}
}
}

Expand Down

0 comments on commit 19f7e07

Please sign in to comment.