codefori / vscode-ibmi

🌍 IBM i development extension for VS Code
https://codefori.github.io/docs/#/
MIT License
279 stars 93 forks source link

QSH Compilation Command Fails When Library Name Contains '#' #1672

Closed bpmcpherson closed 9 months ago

bpmcpherson commented 9 months ago

Hello all,

In the shell commands generated by the compilation actions, I noticed that no matter what I did, they seemed to fail with no output and little to no traceability. As a result, I did everything from check all possible SSH settings, file permissions, updates and reinstallations to no avail.

liblist -d MYLIBCMD MYLIB LEGACY QGPL PRJPRDDTA PRJPRDOBJ #MENUI3 && liblist -c PRJPRDOBJ && liblist -a BMCPHERSON MYLIB PRJPRDOBJ QGPL QTEMP #MENUI3 && system "CRTSQLRPGI OBJ(PRJPRDOBJ/RPG101) SRCFILE(PRJPRDOBJ/QRPGLESRC) SRCMBR(RPG101) OPTION(EVENTF) DBGVIEW(SOURCE) OBJTYPE(PGM) TGTRLS(CURRENT)"; if [[ $? -ne 0 ]]; then exit 1; fi

Run independently, I could see that the command would last mention interacting with "PRJPRDOBJ", but not #MENUI3. When I removed all instances of it from the command, it ran exactly as expected. Additionally, surrounding the library name with single quotes allowed it to function.

Is it be possible in the buildLiblistCommands under the CompileTools.ts file to include an additional replacement using a regex expression to hunt down any of the library names which contain characters bash will not like and surround them with quotes?

Thanks!


Context Version
Code for IBM i version 2.4.0
Visual Studio Code version 1.84.2
Operating System win32_x64
Active extensions ``` COBOL (cobol): 9.11.10 Code for IBM i Walkthroughs (vscode-ibmi-walkthroughs): 0.4.0 Db2 for IBM i (vscode-db2i): 0.5.2 Emmet (emmet): 1.0.0 Error Lens (errorlens): 3.15.0 Git (git): 1.0.0 Git Base (git-base): 1.0.0 GitHub (github): 0.0.1 GitHub Authentication (github-authentication): 0.0.2 JSON Language Features (json-language-features): 1.0.0 Merge Conflict (merge-conflict): 1.0.0 Node Debug Auto-attach (debug-auto-launch): 1.0.0 TODO Highlight (vscode-todo-highlight): 1.0.5 TypeScript and JavaScript Language Features (typescript-language-features): 1.0.0 WSL: Recommender (remote-wsl-recommender): 0.0.19 ```

Remote system |Setting|Value| |-|-| |IBM i OS|V7R4M0| |Tech Refresh|6| |CCSID|37| |SQL|Disabled |Source dates|Disabled ### Enabled features |/QOpenSys/pkgs/bin|/usr/bin|/QSYS.lib/ILEDITOR.lib|/QSYS.LIB| |-|-|-|-| |bash|attr|GENCMDXML.PGM|QZDFMDB2.PGM| |chsh|iconv|GETNEWLIBL.PGM|| |git|setccsid||| |grep|||| |ls|||| |md5sum|||| |sort|||| |stat|||| |tar|||| |tn5250||||
worksofliam commented 9 months ago

Please share the contents of your Code for IBM i output channel after it fails.

image
chrjorgensen commented 9 months ago

@worksofliam The error is real - having # as the first character in a library name (like #LIBRARY) will create a liblist command with space and #lib... which is a comment in the shell!

I'm working on a fix!

bpmcpherson commented 9 months ago

@worksofliam Hi Barry,

Just for the sake of being thorough, I wanted to share the output you requested. I apologize for how much of it is sanitized, but the problem library is shown.

codeforibmi_compilation_output_ticket_1672

As you can see, there is no obvious error output. However, breaking apart the statement and running them manually allowed me to see where the command was stopping.

@chrjorgensen I appreciate you jumping on the problem! However, and I don't know the rules for library names, but does the sanitization or quoting solution also need to account for '#' (or any other special characters for that matter) being not just at the beginning of the name?

chrjorgensen commented 9 months ago

@bpmcpherson

does the sanitization or quoting solution also need to account for '#' (or any other special characters for that matter) being not just at the beginning of the name?

No - it's only when the '#' is in the beginning of the library name and comes after a space, that it will be considered a comment, so the sanitize routine only checks the first character in the library name.