next | next | up | down | Inhalt | Uebungen | Complete | Kommentar

all, section 7.5.

7.5.  echo

Die folgende Funktion beruht auf einer Idee von Skalla und ist portabel:

 1      #!/bin/sh
 2      
 3      prompt() { # arg ...
 4              c=`echo '\c'`
 5              n=; : ${c:+${n:=-n}}
 6              c=; : ${n:-${c:=\\c}}
 7              echo $n "$@"$c
 8      }
 9      
10      [ prompt = `PATH=/usr/ucb:/bin:/usr/bin basename "$0"` ] && prompt "$@"

Man kann prompt auf verschiedene Arten aufrufen:

$ set a b c
$ . prompt; type prompt
prompt is a function
prompt(){
c=`echo '` 
n= 
: ${c:+${n:=-n}} 
c= 
: ${n:-${c:=} 
echo $n "$@"$c 
}
$ prompt a b c
a b c$ unset prompt; prompt a b c
a b c$ type prompt
prompt is hashed (prompt)


back | next | up | down | Inhalt | Uebungen | Complete | Kommentar


Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).

Last modified 03/July/97