From 671fd022035dbc2fc5a1650ec53c8221f4358112 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Fri, 17 Nov 2023 08:12:42 -0500 Subject: [PATCH 1/2] Add code to escape member names when doing resolve --- src/api/IBMiContent.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/IBMiContent.ts b/src/api/IBMiContent.ts index 6b64152fb..b7c911a22 100644 --- a/src/api/IBMiContent.ts +++ b/src/api/IBMiContent.ts @@ -651,7 +651,9 @@ export default class IBMiContent { } async memberResolve(member: string, files: QsysPath[]): Promise { - const command = `for f in ${files.map(file => `/QSYS.LIB/${file.library.toUpperCase()}.LIB/${file.name.toUpperCase()}.FILE/${member.toUpperCase()}.MBR`).join(` `)}; do if [ -f $f ]; then echo $f; break; fi; done`; + // Escape names for shell + const fixed = files.map(f => ({name: f.name.replace(/([$\\])/g,'\\$1'), library: f.library.replace(/([$\\])/g,'\\$1')})); + const command = `for f in ${fixed.map(file => `/QSYS.LIB/${file.library.toUpperCase()}.LIB/${file.name.toUpperCase()}.FILE/${member.toUpperCase()}.MBR`).join(` `)}; do if [ -f $f ]; then echo $f; break; fi; done`; const result = await this.ibmi.sendCommand({ command, From b9eed167642694dbbf9b3f874d8c3edd9e25a2e8 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Sat, 18 Nov 2023 20:49:01 -0500 Subject: [PATCH 2/2] Move file list into seperate variable, and escape member name --- src/api/IBMiContent.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/IBMiContent.ts b/src/api/IBMiContent.ts index b7c911a22..5b91ee776 100644 --- a/src/api/IBMiContent.ts +++ b/src/api/IBMiContent.ts @@ -652,9 +652,13 @@ export default class IBMiContent { async memberResolve(member: string, files: QsysPath[]): Promise { // Escape names for shell - const fixed = files.map(f => ({name: f.name.replace(/([$\\])/g,'\\$1'), library: f.library.replace(/([$\\])/g,'\\$1')})); - const command = `for f in ${fixed.map(file => `/QSYS.LIB/${file.library.toUpperCase()}.LIB/${file.name.toUpperCase()}.FILE/${member.toUpperCase()}.MBR`).join(` `)}; do if [ -f $f ]; then echo $f; break; fi; done`; + const pathList = files + .map(file => `/QSYS.LIB/${file.library}.LIB/${file.name}.FILE/${member}.MBR`) + .join(` `) + .replace(/([$\\])/g,'\\$1') + .toUpperCase(); + const command = `for f in ${pathList}; do if [ -f $f ]; then echo $f; break; fi; done`; const result = await this.ibmi.sendCommand({ command, });