jan damborsky wrote: > William James wrote: > > On Tue, Apr 8, 2008 at 4:30 AM, Dave Miner <Dave.Miner at sun.com> wrote: > >> Jan Damborsky wrote: > >> > Hi Sarah, > >> > > >> > I have done changes according to the Dave's and Frank's > >> > suggestions: > >> > > >> > * timeout not implemented > >> > * implemented UI complies with the mock up > >> > > >> > Could you please look at the updated webrev ? > >> > > >> > It is available at > >> > > >> > http://cr.opensolaris.org/~dambi/bug-973-2/ > >> > >> set_lang.bash, 41: should be "To select the desktop..." > > > > Why do you use bash instead of ksh93? > > There was no technical reason not to use ksh93 - I assume ;-) > > As Sanjay already pointed out, this script > is only temporary solution and hack from > design point of view (please see bug report > for details) - different approach will have > to be worked out for next release. > > I chose the bash due to the time constraints - > at that point I was more familiar with bash than > ksh93.
To end this debate - attached is a ksh93 version of the script. I did some minor changes in functionality, e.g. ... - The script now explicitly sets PATH to avoid that any weired stuff gets picked-up by accident - The script now aborts on any internal error, e.g. $ set -o errexit #) - The code now enables the shell's "gmacs" editor mode to allow users to edit their inputs using the cursor keys - The prompt of the "read" is now localised (assuming someone writes a catalog) - The "lang_choice" is now an integer and uses the "read" builtin's facilities for default values - General cleanup per http://www.opensolaris.org/os/project/shell/shellstyle/ - The script now uses the arithmetric operators (( )) , >, < etc. and comparisations for numberic values instead of [[ ]]/-lt/-gt - The code now uses printf when expanding variable values to avoid interpretation of any special shell characters - The language name/lang pairs are now stored in a compound variable array. Technically this should be... -- snip -- typeset -a languages=( ( name="1. Chinese - Simplified" lang="zh_CN.UTF-8" ) ( name="2. Chinese - Traditional" lang="zh_TW.UTF-8" ) ( name="3. English" lang="en_US.UTF-8" ) ( name="4. French" lang="fr_FR.UTF-8" ) ( name="5. German" lang="de_DE.UTF-8" ) ( name="6. Italian" lang="it_IT.UTF-8" ) ( name="7. Japanese" lang="ja_JP.UTF-8" ) ( name="8. Korean" lang="ko_KR.UTF-8" ) ( name="9. Portuguese" lang="pt_BR.UTF-8" ) ( name="10. Russian" lang="ru_RU.UTF-8" ) ( name="11. Spanish" lang="es_ES.UTF-8" ) ( name="12. Swedish" lang="sv_SE.UTF-8" ) ) -- snip -- ... but the ksh93 version in the Indiana demo has a small bug, therefore I fell-back to an alternative (and IMO much uglier) syntax (the ksh93-integration update1 putback will fix that). - I removed the hardcoded number "12" from the script - it will now look at the number of entries in the "languages" array The script is attached as "set_lang.ksh" ... ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz at nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 7950090 (;O/ \/ \O;) -------------- next part -------------- #!/usr/bin/ksh93 # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # export PATH=/usr/bin # enable gmacs mode for editing "read" values set -o gmacs # exit on any errors set -o errexit builtin mkdir # list of suported languages typeset -r -a languages languages[0]=( name=" 1. Chinese - Simplified" lang="zh_CN.UTF-8" ) languages[1]=( name=" 2. Chinese - Traditional" lang="zh_TW.UTF-8" ) languages[2]=( name=" 3. English" lang="en_US.UTF-8" ) languages[3]=( name=" 4. French" lang="fr_FR.UTF-8" ) languages[4]=( name=" 5. German" lang="de_DE.UTF-8" ) languages[5]=( name=" 6. Italian" lang="it_IT.UTF-8" ) languages[6]=( name=" 7. Japanese" lang="ja_JP.UTF-8" ) languages[7]=( name=" 8. Korean" lang="ko_KR.UTF-8" ) languages[8]=( name=" 9. Portuguese" lang="pt_BR.UTF-8" ) languages[9]=( name="10. Russian" lang="ru_RU.UTF-8" ) languages[10]=( name="11. Spanish" lang="es_ES.UTF-8" ) languages[11]=( name="12. Swedish" lang="sv_SE.UTF-8" ) integer -r num_languages=${#languag...@]} # English is the default integer -r def_lang=3 print # list supported languages for (( i=0 ; i < num_languages ; i++ )) ; do print "${languages[i].name}" done # prompt user to select language # check for valid entry # empty string means default choice integer lang_choice=$def_lang while true ; do read -v $"lang_choice?To select desktop language, enter a number: " || true # check for valid option (( lang_choice" >= 1 && lang_choice" <= num_languages )) && break done mkdir -p "/etc/sysconfig" # store the selected language to the gdm configuration file printf "RC_LANG=%s\n" "${languages[lang_choice-1].lang}" > /etc/sysconfig/language exit 0
