File tree 3 files changed +23
-2
lines changed 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 116
116
"type" : " boolean" ,
117
117
"default" : true ,
118
118
"description" : " Whether to scan for additional shell files. Reload window for the changes to take effect."
119
+ },
120
+ "task-explorer.defaultShell" : {
121
+ "type" : " string" ,
122
+ "default" : " /bin/bash" ,
123
+ "description" : " The default shell to use for shell tasks."
119
124
}
120
125
}
121
126
},
Original file line number Diff line number Diff line change @@ -50,7 +50,21 @@ export default class TaskProviderShell implements TaskProvider<ShellTask> {
50
50
const name = basename ( file . path )
51
51
const folder = workspace . getWorkspaceFolder ( file )
52
52
53
- // TODO: Get hashbang
53
+ let executable = this . config . getOr ( 'defaultShell' , '/bin/bash' )
54
+ let shellArgs : string [ ] = [ ]
55
+
56
+ const contents = await workspace . fs . readFile ( file )
57
+ const lines = contents . toString ( ) . split ( '\n' )
58
+ if ( lines . length > 0 ) {
59
+ const firstLine = lines [ 0 ] . replace ( '\r' , '' )
60
+
61
+ if ( firstLine . startsWith ( '#!' ) ) {
62
+ const parts = firstLine . split ( ' ' )
63
+
64
+ executable = parts [ 0 ] . replace ( '#!' , '' )
65
+ shellArgs = parts . slice ( 1 )
66
+ }
67
+ }
54
68
55
69
const task = new ShellTask (
56
70
new ShellTaskDefinition ( ) ,
@@ -61,7 +75,7 @@ export default class TaskProviderShell implements TaskProvider<ShellTask> {
61
75
file . fsPath ,
62
76
{
63
77
cwd : folder ?. uri . fsPath ,
64
- executable : '/bin/bash' ,
78
+ executable, shellArgs
65
79
}
66
80
)
67
81
)
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ export interface ConfigSchema {
8
8
exclude : string [ ]
9
9
10
10
scanShell : boolean
11
+
12
+ defaultShell : string
11
13
}
12
14
13
15
type ConfigKey = keyof ConfigSchema
You can’t perform that action at this time.
0 commit comments