@@ -128,9 +128,19 @@ func shellAction(cmd *cobra.Command, args []string) error {
128
128
}
129
129
script := fmt .Sprintf ("%s ; exec %s --login" , changeDirCmd , shell )
130
130
if len (args ) > 1 {
131
+ quotedArgs := make ([]string , len (args [1 :]))
132
+ parsingEnv := true
133
+ for i , arg := range args [1 :] {
134
+ if parsingEnv && isEnv (arg ) {
135
+ quotedArgs [i ] = quoteEnv (arg )
136
+ } else {
137
+ parsingEnv = false
138
+ quotedArgs [i ] = shellescape .Quote (arg )
139
+ }
140
+ }
131
141
script += fmt .Sprintf (
132
142
" -c %s" ,
133
- shellescape .Quote (shellescape . QuoteCommand ( args [ 1 :] )),
143
+ shellescape .Quote (strings . Join ( quotedArgs , " " )),
134
144
)
135
145
}
136
146
@@ -191,3 +201,13 @@ func shellAction(cmd *cobra.Command, args []string) error {
191
201
func shellBashComplete (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
192
202
return bashCompleteInstanceNames (cmd )
193
203
}
204
+
205
+ func isEnv (arg string ) bool {
206
+ return len (strings .Split (arg , "=" )) > 1
207
+ }
208
+
209
+ func quoteEnv (arg string ) string {
210
+ env := strings .SplitN (arg , "=" , 2 )
211
+ env [1 ] = shellescape .Quote (env [1 ])
212
+ return strings .Join (env , "=" )
213
+ }
0 commit comments