func prepInteractiveCommand(ctx *ctx) (*exec.Cmd, error) {
	var (
		err      error
		runShell bool
	)
	// determine shell for the given OS user:
	if ctx.exec.cmdName == "" {
		runShell = true
		ctx.exec.cmdName, err = utils.GetLoginShell(ctx.login)
		if err != nil {
			log.Error(err)
			return nil, trace.Wrap(err)
		}
		// in test mode short-circuit to /bin/sh
		if ctx.isTestStub {
			ctx.exec.cmdName = "/bin/sh"
		}
	}
	c, err := prepareCommand(ctx)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	// this configures shell to run in 'login' mode
	if runShell {
		c.Args[0] = "-" + filepath.Base(ctx.exec.cmdName)
	}
	return c, nil
}
// prepInteractiveCommand configures exec.Cmd object for launching an interactive command
// (or a shell)
prepInteractiveCommand configures exec.Cmd object for launching an interactive command
(or a shell)
// prepInteractiveCommand configures exec . Cmd object for launching an interactive command // ( or a shell )
func prepInteractiveCommand(ctx *ctx) (*exec.Cmd, error) {
	var (
		err      error
		runShell bool
	)
	if ctx.exec.cmdName == "" {
		runShell = true
		ctx.exec.cmdName, err = utils.GetLoginShell(ctx.login)
		if err != nil {
			log.Error(err)
			return nil, trace.Wrap(err)
		}
		if ctx.isTestStub {
			ctx.exec.cmdName = "/bin/sh"
		}
	}
	c, err := prepareCommand(ctx)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	if runShell {
		c.Args[0] = "-" + filepath.Base(ctx.exec.cmdName)
	}
	return c, nil
}
func prepInteractiveCommand ( ctx * ctx ) ( * exec . Cmd , error ) { var ( err error runShell bool ) if ctx . exec . cmdName == " " { runShell = true ctx . exec . cmdName , err = utils . GetLoginShell ( ctx . login ) if err != nil { log . Error ( err ) return nil , trace . Wrap ( err ) } if ctx . isTestStub { ctx . exec . cmdName = " " } } c , err := prepareCommand ( ctx ) if err != nil { return nil , trace . Wrap ( err ) } if runShell { c . Args [ 0 ] = " " + filepath . Base ( ctx . exec . cmdName ) } return c , nil }
prepInteractiveCommand configures exec.Cmd object for launching an interactive command
(or a shell)
prepInteractiveCommand configures exec . Cmd object for launching an interactive command ( or a shell )
// determine shell for the given OS user: // in test mode short-circuit to /bin/sh // this configures shell to run in 'login' mode