v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
660 stars 58 forks source link

leading "-" (minus) in value breaks output #104

Closed frostworx closed 3 years ago

frostworx commented 3 years ago

Hi, First of all great program, thanks a lot! Currently I'm implementing a yad settings menu in my steamtinkerlaunch and noticed, that yad has problems with a leading "-" (minus) in variables, which breaks the whole config, as the entry is skipped and destroys the order of all config options. I workaround this, by adding a " " (space) before the minus in the variable directly in the yad command, which seems to work as it should. Here's a little example, which demonstrates the issue:

#!/bin/bash

CMDARGS="-leading -minus breaks"

yad --form --separator="\n" --quoted-output \
--text="<span font_weight='bold'>Settings for Game</span>" \
--field="commandline arguments" "$CMDARGS"

# with this parameter extension it works:
#--field="commandline arguments" "${CMDARGS/#-/ -}"

If there's anything else you need please tell me.

v1cont commented 3 years ago

simply add -- (two dashes) before $CMDARG

this is working

yad --form --separator="\n" --quoted-output \
    --text="<span font_weight='bold'>Settings for Game</span>" \
    --field="commandline arguments" -- "$CMDARGS"
frostworx commented 3 years ago

Oh my.... Thank you very much for your quick reply! closing here

frostworx commented 3 years ago

Sorry, closed it too early. Indeed this works for one argument, but I have multiple and yad stops after the first one:

#!/bin/bash

CMDARGS="-leading -minus breaks"
OTHERARGS="-second -of -multiple -lines"

yad --form --separator="\n" --quoted-output \
--text="<span font_weight='bold'>Settings for Game</span>" \
--field="commandline arguments" -- "$CMDARGS" \
--field="other arguments" -- "$OTHERARGS"

Would be great if you had a hint :)

v1cont commented 3 years ago

-- is a usual separator for options and arbitrary arguments. if some of your arguments started with dash, don't mix them with options.

yad --form --separator="\n" --quoted-output \
--text="<span font_weight='bold'>Settings for Game</span>" \
--field="commandline arguments" --field="other arguments" \
-- "$CMDARGS" "$OTHERARGS"
frostworx commented 3 years ago

Great, that works (I knew double dash, but tbh I never ever had any real life need for it...)... Thank you very much for your help! Very appreciated!