File tree Expand file tree Collapse file tree 2 files changed +88
-3
lines changed
src/Compute/Compute.Autorest/custom Expand file tree Collapse file tree 2 files changed +88
-3
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,50 @@ function Set-AzVMRunCommand_ScriptLocalPath {
180
180
if ($PSBoundParameters.ContainsKey (" ScriptLocalPath" ))
181
181
{
182
182
# Read Local File and add
183
- $script = (Get-Content - Path $ScriptLocalPath ) -join " ;"
183
+ $script = " "
184
+ if ((Get-ChildItem $scriptLocalPath | Select-Object Extension).Extension -eq " .sh" ){
185
+ foreach ($line in Get-Content - Path $scriptLocalPath ){
186
+ $words = $line.trim ().split()
187
+ $commentFound = $false
188
+ foreach ($word in $words ){
189
+ if ($word [0 ] -eq " #" -and $commentFound -eq $false ){
190
+ $commentFound = $true
191
+ $script += " `` " + $word + " "
192
+ }
193
+ else {
194
+ $script += $word + " "
195
+ }
196
+ }
197
+ $script = $script.trim ()
198
+ # close
199
+ if ($commentFound ){
200
+ $script += " `` "
201
+ }
202
+ $script += " ;"
203
+ }
204
+ }
205
+ else {
206
+ foreach ($line in Get-Content - Path $scriptLocalPath ){
207
+ $words = $line.trim ().split()
208
+ $commentFound = $false
209
+ foreach ($word in $words ){
210
+ if ($word [0 ] -eq " #" -and $commentFound -eq $false ){
211
+ $commentFound = $true
212
+ $script += " <" + $word + " "
213
+ }
214
+ else {
215
+ $script += $word + " "
216
+ }
217
+ }
218
+ $script = $script.trim ()
219
+ # close
220
+ if ($commentFound ){
221
+ $script += " #>"
222
+ }
223
+ $script += " ;"
224
+ }
225
+ }
226
+
184
227
$PSBoundParameters.Add (" SourceScript" , $script )
185
228
# If necessary, remove the -ParameterA parameter from the dictionary of bound parameters
186
229
$null = $PSBoundParameters.Remove (" ScriptLocalPath" )
Original file line number Diff line number Diff line change @@ -185,8 +185,50 @@ function Set-AzVmssVMRunCommand_ScriptLocalPath {
185
185
process {
186
186
if ($PSBoundParameters.ContainsKey (" ScriptLocalPath" ))
187
187
{
188
- # Read Local File and add
189
- $script = (Get-Content - Path $ScriptLocalPath ) -join " ;"
188
+ # Read Local File and add
189
+ $script = " "
190
+ if ((Get-ChildItem $scriptLocalPath | Select-Object Extension).Extension -eq " .sh" ){
191
+ foreach ($line in Get-Content - Path $scriptLocalPath ){
192
+ $words = $line.trim ().split()
193
+ $commentFound = $false
194
+ foreach ($word in $words ){
195
+ if ($word [0 ] -eq " #" -and $commentFound -eq $false ){
196
+ $commentFound = $true
197
+ $script += " `` " + $word + " "
198
+ }
199
+ else {
200
+ $script += $word + " "
201
+ }
202
+ }
203
+ $script = $script.trim ()
204
+ # close
205
+ if ($commentFound ){
206
+ $script += " `` "
207
+ }
208
+ $script += " ;"
209
+ }
210
+ }
211
+ else {
212
+ foreach ($line in Get-Content - Path $scriptLocalPath ){
213
+ $words = $line.trim ().split()
214
+ $commentFound = $false
215
+ foreach ($word in $words ){
216
+ if ($word [0 ] -eq " #" -and $commentFound -eq $false ){
217
+ $commentFound = $true
218
+ $script += " <" + $word + " "
219
+ }
220
+ else {
221
+ $script += $word + " "
222
+ }
223
+ }
224
+ $script = $script.trim ()
225
+ # close
226
+ if ($commentFound ){
227
+ $script += " #>"
228
+ }
229
+ $script += " ;"
230
+ }
231
+ }
190
232
$PSBoundParameters.Add (" SourceScript" , $script )
191
233
# If necessary, remove the -ParameterA parameter from the dictionary of bound parameters
192
234
$null = $PSBoundParameters.Remove (" ScriptLocalPath" )
You can’t perform that action at this time.
0 commit comments