Dialog: Unterschied zwischen den Versionen

Aus Thomas Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
 
Zeile 10: Zeile 10:
  # Copyright: 2004 by Thomas Arend
  # Copyright: 2004 by Thomas Arend
  #
  #
 
  clean_exit () {
  clean_exit () {
 
  # Insert here what has to be done before the script exits
  # Insert here what has to be done before the script exits
   
   

Aktuelle Version vom 21. Januar 2012, 16:11 Uhr

dialog, kdialog, Xdialog

Muster-Template für ein Script, das dialog, kdialog oder Xdialog verwendet. Dabei wird Xdialog der Vorzug vor kdialog gegeben. Achtung: Xdialog beginnt wirklich mit einem Großbuchstaben.

#! /bin/bash
#
# Template for scripts using Xdialog, kdialog or dialog
# Licence:	GPL, FDL
# Author:	Thomas Arend
# Copyright:	2004 by Thomas Arend
#

clean_exit () {

# Insert here what has to be done before the script exits

echo "Finished! I hope everything worked fine."
}

trap clean_exit EXIT 

DIALOG="dialog"
[ -n "$DISPLAY" ] && [ -x "`type -p kdialog`" ] && DIALOG="kdialog"
[ -n "$DISPLAY" ] && [ -x "`type -p Xdialog`" ] && DIALOG="Xdialog"

export XDIALOG_HIGH_DIALOG_COMPAT=1

$DIALOG --yesno "$DIALOG" 5 40

Die drei Varianten von dialog, kdialog und Xdialog sind hinsichtlich der Parameter nicht uneingeschränkt kompatibel. Ein Script, das mit allen drei Programmen läuft, muss sehr sorgfältig geplant werden und benötigt in der Regel zusätzliche Unterscheidungen vor einen Dialogaufruf.