YAD field negative numbers

Asked by Brian Stewart

I'm sure I'm missing something here, BASH is new to me!
I am trying to create a script using dialog entry (YAD).
A few of the form fields require a number which has a negative value as a default.
I can set a range from -5 to +10 but I cannot seem to set the initial value to a negative value.

If I set VALUE = 0 or another positive number things work OK.
If I set VALUE=0-2 then the range works OK but the initial value starts as 0 and not -2
I don't seem to be able to set the initial (Defailt) value to a negative number.

What am I doing wrong?

#!/bin/sh

VALUE=-2 #-2 messes up range in yad. 0-2 (zero minus 2) gives correct range but initial value becomes 0 not -2.
MIN=-5
MAX=10

yad --title="Negative number test"\
    --form --field="number:NUM" ${VALUE}!${MIN}..${MAX}!1!0

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu yad Edit question
Assignee:
No assignee Edit question
Solved by:
Colin Watson
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

I suggest you report a bug

Revision history for this message
Brian Stewart (brianstew) said :
#2

Hi, many thanks for your reply.
Does this appear to be a bug or is it just my poor understanding of how things work?

Revision history for this message
Best Colin Watson (cjwatson) said :
#3

It's not a bug, no (except possibly that yad perhaps ought to have been able to fail with an informative error message rather than silently doing the wrong thing). The problem occurs because a parameter that starts with "-" is parsed as an option. If you replace the last bit of your script with:

yad --title="Negative number test"\
    --form --field="number:NUM" -- ${VALUE}!${MIN}..${MAX}!1!0

... then it works fine ("--" is a convention used by many option parsers to indicate "end of options").

Revision history for this message
Brian Stewart (brianstew) said :
#4

Thanks Colin Watson, that solved my question.

Revision history for this message
Brian Stewart (brianstew) said :
#5

Many thanks Colin.
This did indeed solve my problem.
Due to my lack of experience with bash I was more confident that it was my own interpretation than a real bug.

We each have our own specialities, and sadly mine is not in this area but I'm trying to improve and thanks to people such as you this helps me on my way.

Thank you!