Skip to content

Commit 5d4b4d7

Browse files
committed
Use exec check
1 parent eede534 commit 5d4b4d7

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/connection/sqlJob.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,42 @@ export class SQLJob {
4646

4747
id: string | undefined;
4848

49-
5049
public static getNewUniqueId(prefix: string = `id`): string {
5150
return prefix + (++SQLJob.uniqueIdCounter);
5251
}
5352

53+
public static async useExec() {
54+
let useExec = false;
55+
56+
const instance = getInstance();
57+
const connection = instance.getConnection();
58+
59+
const bashPathAvailable = connection.remoteFeatures[`bash`];
60+
if (bashPathAvailable) {
61+
const commandShellResult = await connection.sendCommand({
62+
command: `echo $SHELL`
63+
});
64+
if (!commandShellResult.stderr) {
65+
let userDefaultShell = commandShellResult.stdout.trim();
66+
if (userDefaultShell === bashPathAvailable) {
67+
useExec = true;
68+
}
69+
}
70+
}
71+
72+
return useExec;
73+
}
74+
5475
constructor(public options: JDBCOptions = {}) {}
5576
private async getChannel() {
5677
const instance = getInstance();
5778
const connection = instance.getConnection();
79+
80+
let useExec = await SQLJob.useExec();
81+
5882
return new Promise((resolve, reject) => {
5983
// Setting QIBM_JAVA_STDIO_CONVERT and QIBM_PASE_DESCRIPTOR_STDIO to make sure all PASE and Java converters are off
60-
const startingCommand = `QIBM_JAVA_STDIO_CONVERT=N QIBM_PASE_DESCRIPTOR_STDIO=B QIBM_USE_DESCRIPTOR_STDIO=Y QIBM_MULTI_THREADED=Y ` + ServerComponent.getInitCommand();
84+
const startingCommand = `QIBM_JAVA_STDIO_CONVERT=N QIBM_PASE_DESCRIPTOR_STDIO=B QIBM_USE_DESCRIPTOR_STDIO=Y QIBM_MULTI_THREADED=Y ${useExec ? `exec ` : ``}` + ServerComponent.getInitCommand();
6185

6286
ServerComponent.writeOutput(startingCommand);
6387

0 commit comments

Comments
 (0)