Hi, thanks for that valuable hint! I have rewritten my script to use arrays (and encapsulated adding parameters to it). Now I just need to rewrite multiple parameters to single... :(
Regards, Roland On Fri, 2011-04-08 at 23:28 +0200, Pascal J. Bourguignon wrote: > On 2011/04/08, at 14:45 , Roland Häder wrote: > > > Hi all, > > > > for example the airport LFPG has a parking position with a name with > > spaces in it. My little launcher script [1] does currently not support > > this because of a for() loop will break those spaces into seperate > > lines. > > > > Assume that ${OPTIONS} is the list of command-line parmeters (I know, I > > should rename that): > > > > -------------- Snip ------------ > > # Flushs all options to ~/.fgfsrc > > fgfs_flush_options() { > > echo "$0: Flushing options to ~/.fgfsrc ..." > > echo -n "" > "${HOME}/.fgfsrc" > > for entry in ${OPTIONS}; do > > echo "${entry}" >> "${HOME}/.fgfsrc" > > done > > } > > -------------- Snap ------------ > > > > Can those "spaced names" be fixed e.g. to names with underscores? Or > > won't FGFS (latest GIT/master here) find them? > > > > If not, can I somehow support them in my script? > > If you write OPTIONS as an array: > > OPTIONS=( --airport=LFPG --parking='P 12' ) > > then you can write: > > for option in "${OPTIONS[@]}" ; do > printf "%s\n" "$option" > done >> "${HOME}/.fgfsrc" > > Now, while we get one option per line, we lose the quote in .fgfsrc. > > If you need the quote there, then you may add them in a ad-hoc manner: > > OPTIONS=( --airport=LFPG --parking="'P 12'" ) > > or you may quote systematically all the options you write: > > for option in "${OPTIONS[@]}" ; do > printf "'%s'\n" "$option" > done >> "${HOME}/.fgfsrc" > > but this would break if there is an option containing single quote. > To do the right thing, you have to know exactly how .fgfsrc is processed. > > >
signature.asc
Description: This is a digitally signed message part
------------------------------------------------------------------------------ Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev
_______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel