AppImageCrafters / AppRun

AppDir runtime components
MIT License
26 stars 10 forks source link

AppRun calls programs incorrectly when EXEC_ARGS includes $@ preceded by any arguments #31

Closed marcinsulikowski closed 3 years ago

marcinsulikowski commented 3 years ago

I noticed that AppRun executes programs with an invalid list of parameters (it adds a spurious empty argument) when EXEC_ARGS in .env includes any arguments before $@.

I'd like AppRun to call an executable with a predefined list of arguments, followed by any extra arguments that user passes to AppRun itself. An example is the following in .env:

EXEC_PATH=$APPDIR/opt/python3/bin/python
EXEC_ARGS=$APPDIR/opt/app/script.py $@

With such an .env file, I'd expect ./AppRun to pass the following arguments to execv:

"(...)/opt/python3/bin/python" "(...)/opt/app/script.py"

and ./AppRun --something to pass the following arguments to execv:

"(...)/opt/python3/bin/python" "(...)/opt/app/script.py" "--something"

Unfortunately, whereas the latter works as expected, executing ./AppRun with no arguments passes the following to execv:

"(...)/opt/python3/bin/python" "(...)/opt/app/script.py" ""

The extra empty argument causes problems for the application executed by AppRun.

I can see that apprun_shell_expand_variables("$APPDIR/opt/app/script.py $@", argv) returns "(...)/opt/app/script.py " (i.e., a string with a trailing space). This is then passed to apprun_shell_split_arguments("(...)/opt/app/script.py ") which in turn returns an array with two elements: "(...)/opt/app/script.py" and "".

I'm not sure if that makes sense, but I think apprun_shell_split_arguments could trim trailing whitespace like it seems to do with leading whitespace.

azubieta commented 3 years ago

Thanks for reporting, working on it right now.

azubieta commented 3 years ago

Could you please test your bundle using the AppRun and libapprun hooks from this build?

Unzip the file and replace the AppRun in your AppDir by the one inside. Please make sure of selecting the right binary for your arch.

azubieta commented 3 years ago

Please test using the binaries from the latest continuous build. Feel free to reopen if the issue persist.

marcinsulikowski commented 3 years ago

After adding the following to my recipe:

  runtime:
    version: "continuous"

to use the latest runtime, the created AppImage bundle works as expected. Thank you!

azubieta commented 3 years ago

Excellent let's make a release :)