help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: spaces


From: Pascal
Subject: Re: spaces
Date: Wed, 26 Jan 2022 11:17:08 +0100

the variable call is a little less pleasant visually and to write but has
the big advantage to work ! 😂
thanks to you. 👍

Le mer. 26 janv. 2022 à 11:08, Andreas Kusalananda KÀhÀri <
andreas.kahari@abc.se> a Ă©crit :

> On Wed, Jan 26, 2022 at 10:55:37AM +0100, Pascal wrote:
> > hi,
> >
> > I use yad to provide a graphical user interface to some command line
> > programs.
> > yad can require a lot of options so, for more visibility, I define these
> > options in variables like this :
> >
> > yad_general_options="
> > --title=title
> > --sticky
> > --center
> > --icon=icon
> > "
> > yad_progress_options="
> > --progress
> > --pulsate
> > "
> > yad_success_options="
> > --image=success
> > --button=Ok
> > "
> >
> > and I call yad like this :
> >
> > yad $yad_general_options $yad_progress_options --text="the nice text"
> > yad $yad_general_options $yad_success_options --text="the operation was a
> > success"
> >
> > everything works fine as long as no option incorporates a space.
> > what if I want to put "my nice title" in the --title option ?
> > I tried a lot of combinations based on \ and $ but nothing works :-(
> >
> > regards, lacsaP.
>
> yad_general_options=(
> --title="Whatever ** ** ** goes here"
> --sticky
> --center
> --icon=icon
> )
>
> yad_progress_options=(
> --progress
> --pulsate
> )
>
> yad "${yad_general_options[@]}" "${yad_progress_options[@]}" --text="the
> nice text"
>
>
> In short, don't ever demote a list of separate strings into a single
> string when you can store them as separate strings in an array.  Note
> that the quoting of the array expansion is crucial.
>
> Greg will likely have something about in his FAQ, and there is also
> numerous examples of this on the Unix & Linux Stackexchange site, and in
> the mailing list archive of this mailing list.
>
> https://mywiki.wooledge.org/BashGuide/Arrays
>
> https://unix.stackexchange.com/questions/459367/using-shell-variables-for-command-options
>
>
>
> --
> Andreas (Kusalananda) KÀhÀri
> SciLifeLab, NBIS, ICM
> Uppsala University, Sweden
>
> .
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]