Parent Parent directory variable exists ? #3146
|
I want to do something like this: And what is missing for me is a variable which would hold WWSSRC, which is in our git project hierarchy present like this: WWSSRC/QRPGLESRC/Programm.rpgle and QRPGLESRC can be fetched with &PARENT but WWSSRC is not possible to get. This is the output of all variables currently available: &RELATIVEPATH = wwssrc/qrpglesrc/program.rpgle, |
Replies: 3 comments 3 replies
|
Corresponding Pull Request resolving this issue #3149 |
|
There is no &PARENTPARENT variable because it's not a usual use case (heck, someone could even come and ask for PARENTPARENTPARENT for that matter 😉). The actions should remain general purpose only, and are not meant to be a build tool. This is something that fits your particular use case, though. In this case, I'd suggest you add a shell script to your project that could take care of that particular need (and encapsulate the call to both commands). The Unix commands For example: echo "/home/User/wwssrc/qrpglesrc" | xargs dirname | xargs basename
# prints "wwssrc" Having that script would also have the benefit of having that build logic be reused outside of VS Code, in CI/CD pipeline or a build tool, for example. |
|
For people from the future: I created a .sh script inside the IFS filesystem and executed it with parameters from local actions.json based on the answer from sebjulliand like this: {
"name": "Create RPGLE Program and update source member",
"command": "QSH CMD('/QOpenSys/usr/bin/sh /home/User/buildscripts/build-ibmi.sh ''rpgle-pgm'' ''&FULLPATH'' ''&RELATIVEPATH'' ''&PARENT'' ''&NAME'' ''&CURLIB''')",
"deployFirst": true,
"environment": "ile",
"extensions": [
"RPGLE"
]
},Inside the sh script i disassembled the full path so i could get the parent of the parent sh script header looks like this: #!/QOpenSys/usr/bin/sh
set -eu
MODE="$1"
FULLPATH="$2"
RELATIVEPATH="$3"
PARENT="$4"
NAME="$5"
CURLIB="$6"
TOPDIR="$(basename "$(dirname "$(dirname "$FULLPATH")")")"
TOPLIB="$(printf '%s' "$TOPDIR" | tr '[:lower:]' '[:upper:]')"
SRCFILE="$(printf '%s' "$PARENT" | tr '[:lower:]' '[:upper:]')"
NAMEU="$(printf '%s' "$NAME" | tr '[:lower:]' '[:upper:]')" |
There is no &PARENTPARENT variable because it's not a usual use case (heck, someone could even come and ask for PARENTPARENTPARENT for that matter 😉). The actions should remain general purpose only, and are not meant to be a build tool.
This is something that fits your particular use case, though. In this case, I'd suggest you add a shell script to your project that could take care of that particular need (and encapsulate the call to both commands). The Unix commands
dirname,basenameandxargsare available in bash and could help you get the name of that particular folder.For example:
Having that scri…