0

How can I pass arguments from a bash script to a binary?

I have a desktop file app.desktop and an wrapper app.wrapper that calls the app binary. I want to have app.desktop calling the wrapper with Exec=./app.wrapper arg1 arg3 -a arg4 then from the app.wrapper to pass it to /usr/bin/app.

How can I easily do this?

Example of wrapper file:

#!/bin/bash

SCALE=$(( $GRID_UNIT_PX / 8 ))

export GDK_BACKEND=x11
export GDK_SCALE=$SCALE

exec usr/bin/app args here

Thanks.

  • 1
    In the same way as passing it to another script. Binary executables are, from the viewpoint of bash, not different from executable scripts. See the section _SHELL BUILTIN COMMANDS_ in the bash man page, which describes the `exec` command. Of course a more interesting question would be, why you are using `exec` when running your binary. I hope you know what you are doing here. – user1934428 Mar 09 '22 at 13:47
  • Yeah, exec is probably not needed. same for `user/bin/app`, just type `app`, as `/usr/bin` is usually already in your `$PATH` – Aserre Mar 09 '22 at 13:50
  • And `export` isn't really needed either; you can simply `GDK_BACKEND="x11" GDK_SCALE=$((GRID_UNIT_PX / 8)) exec app "$@"` – tripleee Mar 09 '22 at 14:14

0 Answers0