You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "dlmarion (via GitHub)" <gi...@apache.org> on 2023/08/16 13:39:18 UTC

[GitHub] [accumulo] dlmarion opened a new issue, #3697: ACCUMULO_JAVA_PREFIX in accumulo shell script not expanding correctly

dlmarion opened a new issue, #3697:
URL: https://github.com/apache/accumulo/issues/3697

   The `*` subscript in `ACCUMULO_JAVA_PREFIX` at https://github.com/apache/accumulo/blob/38c261d1236f118ffc2c6eebc505f5daf12bf0e2/assemble/bin/accumulo#L86 is expanding the array to a single word separated by `IFS`. In testing, I believe `@` should be used here instead.
   
   **Versions (OS, Maven, Java, and others, as appropriate):**
    - Affected version(s) of this project: 2.10
   
   **To Reproduce**
   I wrote a script to test this out. The following fails:
   ```
   ACCUMULO_JAVA_PREFIX=(
           '/usr/bin/numactl'
           '--all'
   )
   
   CMD=("${ACCUMULO_JAVA_PREFIX[*]}" "/usr/bin/java")
   
   echo "${CMD[@]}"
   exec "${CMD[@]}" "--version"
   ```
   
   Changing `*` to `@` on the line starting with `CMD=` allows the script to succeed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] ctubbsii commented on issue #3697: ACCUMULO_JAVA_PREFIX in accumulo shell script not expanding correctly

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on issue #3697:
URL: https://github.com/apache/accumulo/issues/3697#issuecomment-1680928801

   I will continue to look into this to see if there's something we should do to change this, so you can use an array. But there are trade-offs here that make no option perfect. If we use an array, you can't export it, and if you unintentionally set a scalar when we expect an array, we might not parse it correctly. If we expect a scalar and split it on IFS, then that could be a huge problem for quoting, requiring a bunch of convoluted quoting escapes, and assumptions about how the args are flattened when our script uses the environment variable. There's a good chance that the best option is to leave it as-is, and interpret it as a single scalar, requiring users to put multiple arguments into a script as suggested above.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] asfgit closed issue #3697: ACCUMULO_JAVA_PREFIX in accumulo shell script not expanding correctly

Posted by "asfgit (via GitHub)" <gi...@apache.org>.
asfgit closed issue #3697: ACCUMULO_JAVA_PREFIX in accumulo shell script not expanding correctly
URL: https://github.com/apache/accumulo/issues/3697


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] ctubbsii commented on issue #3697: ACCUMULO_JAVA_PREFIX in accumulo shell script not expanding correctly

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on issue #3697:
URL: https://github.com/apache/accumulo/issues/3697#issuecomment-1680923726

   This may be intended. It is hard for me to remember exactly the reason for making this a scalar, but I think it's related to the fact that it's not possible to export an array in bash.
   
   The workaround (and perhaps the intended behavior) is for the user to write their own prefix command that incorporates all the flags and options they need, and executes with `"$@"`.
   
   So, for example, instead of doing `ACCUMULO_JAVA_PREFIX="numactl --all"`, you could instead do `ACCUMULO_JAVA_PREFIX="mynumactl.sh"` and the contents of `mynumactl.sh` would be `numactl --all "$@"`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] ctubbsii commented on issue #3697: ACCUMULO_JAVA_PREFIX in accumulo shell script not expanding correctly

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on issue #3697:
URL: https://github.com/apache/accumulo/issues/3697#issuecomment-1681175806

   As it turns out, you can jump through hoops to effectively export an array variable, but it's not pretty:
   
   ```bash
   BASH_ENV=<(echo "declare -a ACCUMULO_JAVA_PREFIX='(numactl --all)'") bin/accumulo
   ```
   
   If you set the variable as an array in the environment, but then try to set it as a scalar in the script, then the scalar will only override the first item in the array. This can result in some confusing behavior. I added a sensible check with `declare -p` in my PR #3701 to fix this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org