File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -440,14 +440,18 @@ func (m *Meta) process(args []string) []string {
440440
441441 // Set colorization
442442 m .color = m .Color
443- for i , v := range args {
443+ i := 0 // output index
444+ for _ , v := range args {
444445 if v == "-no-color" {
445446 m .color = false
446447 m .Color = false
447- args = append (args [:i ], args [i + 1 :]... )
448- break
448+ } else {
449+ // copy and increment index
450+ args [i ] = v
451+ i ++
449452 }
450453 }
454+ args = args [:i ]
451455
452456 // Set the UI
453457 m .oldUi = m .Ui
Original file line number Diff line number Diff line change @@ -56,6 +56,21 @@ func TestMetaColorize(t *testing.T) {
5656 if ! m .Colorize ().Disable {
5757 t .Fatal ("should be disabled" )
5858 }
59+
60+ // Test disable #2
61+ // Verify multiple -no-color options are removed from args slice.
62+ // E.g. an additional -no-color arg could be added by TF_CLI_ARGS.
63+ m = new (Meta )
64+ m .Color = true
65+ args = []string {"foo" , "-no-color" , "bar" , "-no-color" }
66+ args2 = []string {"foo" , "bar" }
67+ args = m .process (args )
68+ if ! reflect .DeepEqual (args , args2 ) {
69+ t .Fatalf ("bad: %#v" , args )
70+ }
71+ if ! m .Colorize ().Disable {
72+ t .Fatal ("should be disabled" )
73+ }
5974}
6075
6176func TestMetaInputMode (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments