File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -374,17 +374,23 @@ func configSSH() *cobra.Command {
374
374
// sshConfigAddCoderInclude checks for the coder Include statement and
375
375
// returns modified = true if it was added.
376
376
func sshConfigAddCoderInclude (data []byte ) (modifiedData []byte , modified bool ) {
377
- found := false
377
+ valid := false
378
378
firstHost := sshHostRe .FindIndex (data )
379
379
coderInclude := sshCoderIncludedRe .FindIndex (data )
380
380
if firstHost != nil && coderInclude != nil {
381
381
// If the Coder Include statement exists
382
382
// before a Host entry, we're good.
383
- found = coderInclude [1 ] < firstHost [0 ]
383
+ valid = coderInclude [1 ] < firstHost [0 ]
384
+ if ! valid {
385
+ // Remove invalid Include statement.
386
+ d := append ([]byte {}, data [:coderInclude [0 ]]... )
387
+ d = append (d , data [coderInclude [1 ]:]... )
388
+ data = d
389
+ }
384
390
} else if coderInclude != nil {
385
- found = true
391
+ valid = true
386
392
}
387
- if found {
393
+ if valid {
388
394
return data , false
389
395
}
390
396
You can’t perform that action at this time.
0 commit comments