hop icon indicating copy to clipboard operation
hop copied to clipboard

[Bug]: Execute a process - Single and double quotes are not parsed correctly

Open dave-csc opened this issue 2 months ago • 4 comments

Apache Hop version?

2.15.0

Java version?

17.0.2

Operating system

Linux

What happened?

Steps to reproduce:

  1. Create a Data grid transform, with a single column named command. Enter the following entries (assuming /work/hop/config is an existing folder on your machine):
  • ls -la /work/hop/config (with no quotes)
  • ls -la "/work/hop/config" (with double quotes)
  • ls -la '/work/hop/config' (with single quotes)
  1. Link this to an Execute a process transform, set $[0D] as line delimiter and grab result, error, and exit code in some fields
  2. Link to a Write to log transform to get the output

In a normal Linux terminal all the three commands above will produce the same output (they list the contents of the /work/hop/config folder). In Hop only the first row produces the correct output, the others will throw an error such as Folder '"/work/hop/config"' does not exist.

Issue Priority

Priority: 2

Issue Component

Component: Transforms

dave-csc avatar Nov 11 '25 13:11 dave-csc

A possible workaround is:

  1. in Data grid split the command in chunks, using a field for each chunk. In the example above they could be:
  • command = ls
  • option_la = -la
  • folder = /work/hop/config
  1. in Execute a process enable the option Arguments in fields, then set command as Process field, set also option_la and folder in the Argument fields

A chunk in the Data grid can include spaces and special characters (this is why you would have used the quotes, most likely)

dave-csc avatar Nov 11 '25 14:11 dave-csc

Execute a process is using Runtime.exec(), which has some strange "features". We might be better off using a processBuilder

hansva avatar Nov 11 '25 14:11 hansva

The command indeed is /usr/bin/ls. The rest are arguments.

mattcasters avatar Dec 08 '25 15:12 mattcasters

Hi @mattcasters,

the problem is indeed that you are required to enable the option Arguments in fields to process the arguments correctly (see workaround above).

Without that option, I'd expect to pass a complex command line in the command field as I would do in a normal (Linux) terminal: it actually works when the command doesn't include single or double quotes. When there are those, it seems that command and arguments are just split by spaces, without taking into account that something delimited by quotes is actually a single argument even if it contains spaces.

dave-csc avatar Dec 09 '25 07:12 dave-csc