11package checks
22
33import (
4- "fmt"
54 "os/exec"
65 "strings"
76
@@ -10,15 +9,13 @@ import (
109
1110func CLICommand (
1211 lesson api.Lesson ,
13- optionalPositionalArgs []string ,
1412) []api.CLICommandResult {
1513 data := lesson .Lesson .LessonDataCLICommand .CLICommandData
1614 responses := make ([]api.CLICommandResult , len (data .Commands ))
1715 for i , command := range data .Commands {
18- finalCommand := interpolateArgs (command .Command , optionalPositionalArgs )
19- responses [i ].FinalCommand = finalCommand
16+ responses [i ].FinalCommand = command .Command
2017
21- cmd := exec .Command ("sh" , "-c" , "LANG=en_US.UTF-8 " + finalCommand )
18+ cmd := exec .Command ("sh" , "-c" , "LANG=en_US.UTF-8 " + command . Command )
2219 b , err := cmd .Output ()
2320 if ee , ok := err .(* exec.ExitError ); ok {
2421 responses [i ].ExitCode = ee .ExitCode ()
@@ -29,11 +26,3 @@ func CLICommand(
2926 }
3027 return responses
3128}
32-
33- func interpolateArgs (rawCommand string , optionalPositionalArgs []string ) string {
34- // replace $1, $2, etc. with the optional positional args
35- for i , arg := range optionalPositionalArgs {
36- rawCommand = strings .ReplaceAll (rawCommand , fmt .Sprintf ("$%d" , i + 1 ), arg )
37- }
38- return rawCommand
39- }
0 commit comments