Reduce nestedness in processing of `binlist'.

Now users can use `~' instead of `$HOME' again.
This commit is contained in:
Casper Ti. Vector 2012-11-09 23:23:00 +08:00
parent 2e61a0520e
commit c63e76c680
2 changed files with 9 additions and 8 deletions

View File

@ -104,7 +104,7 @@ else
# Display selection dialog. # Display selection dialog.
binindex=$( binindex=$(
DIALOGRC="$dialogrc" dialog --colors --stdout \ DIALOGRC="$dialogrc" dialog --colors --stdout \
--backtitle "${longname} v${ver}" \ --backtitle "$longname v$ver" \
--ok-label ' Select ' --cancel-label ' Exit ' \ --ok-label ' Select ' --cancel-label ' Exit ' \
--menu 'Select session' 0 0 0 "${menu[@]}" --menu 'Select session' 0 0 0 "${menu[@]}"
) )
@ -116,7 +116,7 @@ fi
# Run $bin according to its flag. # Run $bin according to its flag.
let binindex-=countfrom let binindex-=countfrom
bin="${binlist[${binindex}]}" bin=($(eval echo "${binlist[${binindex}]}"))
case ${flaglist[$binindex]} in case ${flaglist[$binindex]} in
# *C*onsole programs. # *C*onsole programs.
[Cc]) [Cc])
@ -132,7 +132,7 @@ case ${flaglist[$binindex]} in
# ignore SIGINT, which is rather confusing, and cannot be undone. # ignore SIGINT, which is rather confusing, and cannot be undone.
trap - SIGINT SIGTSTP trap - SIGINT SIGTSTP
CDM_SPAWN=$$ exec $bin CDM_SPAWN=$$ exec "${bin[@]}"
;; ;;
# *X* programs. # *X* programs.
@ -175,7 +175,8 @@ case ${flaglist[$binindex]} in
serverargs=(":${display}" "${serverargs[@]}" "vt$vt") serverargs=(":${display}" "${serverargs[@]}" "vt$vt")
$(yesno consolekit) && launchflags=(-c -t "$cktimeout") $(yesno consolekit) && launchflags=(-c -t "$cktimeout")
if cdm-xlaunch "${launchflags[@]}" -- "$bin" -- "${serverargs[@]}"; then if cdm-xlaunch "${launchflags[@]}" -- "${bin[@]}" -- "${serverargs[@]}"
then
exitnormal exitnormal
else else
warn "\`cdm-xlaunch' exited unsuccessfully." warn "\`cdm-xlaunch' exited unsuccessfully."

View File

@ -8,10 +8,10 @@
# #
# (An example:) # (An example:)
# binlist=( # binlist=(
# "$HOME/.xsession" # Launch your X session, # '~/.xsession' # Launch your X session,
# '/bin/bash --login' # or just execute your shell, # '/bin/bash --login' # or just execute your shell,
# '/usr/bin/fbterm' # or start a frame buffer console, # '/usr/bin/fbterm' # or start a frame buffer console,
# "/usr/bin/cdm $HOME/.submenu.cdmrc" # or go to a submenu :) # '/usr/bin/cdm ~/.submenu.cdmrc' # or go to a submenu :)
# ) # )
# List all program display names, one-by-one matched with $binlist. # List all program display names, one-by-one matched with $binlist.