Skip to content

Commit

Permalink
🐛 fix shell command panic (#3410)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev authored Feb 22, 2024
1 parent 123b57d commit aaa3a6c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/cnquery/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func StartShell(runtime *providers.Runtime, conf *ShellConfig) error {
log.Fatal().Msg("could not find an asset that we can connect to")
}

connectAsset := filteredAssets[0]
var connectAsset *scan.AssetWithRuntime
if len(filteredAssets) > 1 {
invAssets := make([]*inventory.Asset, 0, len(filteredAssets))
for _, a := range filteredAssets {
Expand All @@ -116,7 +116,9 @@ func StartShell(runtime *providers.Runtime, conf *ShellConfig) error {
isTTY := isatty.IsTerminal(os.Stdout.Fd())
if isTTY {
selectedAsset := components.AssetSelect(invAssets)
connectAsset = filteredAssets[selectedAsset]
if selectedAsset >= 0 {
connectAsset = filteredAssets[selectedAsset]
}
} else {
fmt.Println(components.AssetList(theme.OperatingSystemTheme, invAssets))
log.Fatal().Msg("cannot connect to more than one asset, use --platform-id to select a specific asset")
Expand Down

0 comments on commit aaa3a6c

Please sign in to comment.