shell script 에서 질문 올립니다.. startx와 Xclients부분...

manji의 이미지

아래 질문 보시면 아시겠지만..
정말 완전 초보 입니다;;
그래도 너그러히 용서하시고 답변해주시면 감사 드리겠습니다 ㅜㅜ

검색도 잘못해서 몇번 검색해봤으나 찾기를 못하겠네요..
글이너무 많은것도 그렇고;;

startx 스크립트와 Xclients 파일의 내용을 완전 분석 하는중입니다.. 그중에 막히는 부분들 때문에 질문 드립니다.
(그파일 소스들을 주석으로 모두 분석해주시는 분이 계시면 공부에 많은 도움이 되겠습니다만... 귀찮으실테니 그냥 궁금한부분들만 질문 드립니다;;)

우선 startx 에서입니다..(이 소스는 제 리눅스 소스와는 약간 다르네요..)
붉은 글씨가 궁금한 부분입니다.. 제가 단 질문은 파란색입니다..

#####시작######

#!/bin/sh

userclientrc=$HOME/.xinitrc
userserverrc=$HOME/.xserverrc
sysclientrc=/etc/X11/xinit/xinitrc
sysserverrc=/etc/X11/xinit/xserverrc
clientargs=""
serverargs=""

if [ -f $userclientrc ]; then
clientargs=$userclientrc
else if [ -f $sysclientrc ]; then
clientargs=$sysclientrc
fi
fi

#1. 여기 if [ -f $userclientrc ]; 라는부분에서 -f 가 어떠한 조건인지 궁금합니다...

if [ -f $userserverrc ]; then
serverargs=$userserverrc
else if [ -f $sysserverrc ]; then
serverargs=$sysserverrc
fi
fi

whoseargs="client"
while [ x"$1" != x ]; do
case "$1" in

/''*|\.*)
if [ "$whoseargs" = "client" ]; then
if [ x"$clientargs" = x ]; then
clientargs="$1"
else
clientargs="$clientargs $1"
fi
else
if [ x"$serverargs" = x ]; then
serverargs="$1"
else
serverargs="$serverargs $1"
fi
fi
;;
--)
whoseargs="server"
;;
*)
if [ "$whoseargs" = "client" ]; then
clientargs="$clientargs $1"
else
case "$1" in
:[0-9]*) display="$1"; serverargs="$serverargs $1";;
*) serverargs="$serverargs $1";;

esac
shift
done
mcookie=`mcookie`
uthfile"

#2. 위에보면 /''*|\.*) 부분과 --) 어떤 의미로 사용되어지는지요...패턴부분인것 같긴한데... *)는 나머지 패턴이라고 하면 저 두개는 뭔지를 모르겠네요...

#3. case "$1" in
# :[0-9]*) display="$1"; serverargs="$serverargs $1";;
# *) serverargs="$serverargs $1";;
#이 부분의 해석이 가능하다면 부탁드립니다. 아예 이해를 못하는 부분이라..

if [ X"$XAUTHORITY" = X ]; then
authfile="$HOME/.Xauthority"
else
authfile="$XAUTHORITY"
fi

serverargs="$serverargs -auth $a";;
xauth add $display . $mcookie
xauth add `hostname -f`$display . $mcookie

#4. add라는 명령어를 모르는데 이게 사용된 이문장의 의미에 대하여..

xinit $clientargs -- $serverargs +xinerama

#####종료#####

startx에서 1~4의 의문점이 있었는데 도움을 요청합니다..

그리고 /etc/X11/xinir/Xclients 의 내용중 의문점입니다.

#####시작#####

#!/bin/bash
# check to see if the user has a preferred desktop
PREFERRED=
if [ -f /etc/sysconfig/desktop ]; then
if [ -n "`grep -i GNOME /etc/sysconfig/desktop`" ]; then
PREFERRED=gnome-session
elif [ -n "`grep -i KDE /etc/sysconfig/desktop`" ]; then
PREFERRED=startkde
elif [ -n "`grep -i AnotherLevel /etc/sysconfig/desktop`" ]; then
PREFERRED=AnotherLevel
fi
fi

if [ -n "$PREFERRED" -a "$PREFERRED" != "AnotherLevel" ] && \
which $PREFERRED >/dev/null 2>&1; then
PREFERRED='which $PREFERRED'
exec $PREFERRED
fi

#1. 이부분 모르겠네요^^; -a 옵션도 모르겠고... -n "$PREFERRED" -a "$PREFERRED" != "AnotherLevel" 이건 동시만족해야하는건가요? $PREFERRED의 문자열
#길이가 0이 아니고 -a "$PREFERRED"가 AnotherLevel과 같지않을때..??
#
#&& \
#which $PREFERRED >/dev/null 2>&1 는 어떻게 쓰여지는건지도 의문이고요..

if [ -z "$PREFERRED" ]; then

GSESSION=gnome-session
STARTKDE=startkde

# by default, we run GNOME.
if which $GSESSION >/dev/null 2>&1; then
exec `which $GSESSION`
eval "exec `which $GSESSION`" > "$HOME"/.gnome-session-errors 2>&1
fi

#2. eval 이라는 구문이 어떻게 쓰이는지요? 이 문장도 모르겠네요 ㅠㅠ

# if GNOME isn't installed, try KDE.
if which $STARTKDE >/dev/null 2>&1; then
exec `which $STARTKDE`
fi
fi

#Last, try AnotherLevel
# these files are left sitting around by TheNextLevel.
rm -f $HOME/Xrootenv.0
rm -f /tmp/fvwmrc* 2>/dev/null

#3. rm -f /tmp/fvwmrc* 이건 fvwmrc로시작하는 모두를 지운다 같은데.. 뒤에 2>/dev/null는 무엇을 의미하는지요?

# First thing - check the user preferences
if [ -f $HOME/.wm_style ] ; then
WMSTYLE=`cat $HOME/.wm_style`
case "$WMSTYLE" in
Afterstep|Afterstep)
exec /usr/X11R6/bin/RunWM --Afterstep
;;
WindowMaker|Windowmaker|Wmaker|wmaker)
exec /usr/X11R6/bin/RunWM --WindowMaker
;;
Fvwm95|fvwm95)
exec /usr/X11R6/bin/RunWM --Fvwm95
;;
Mwm|MWM|Lesstif)
exec /usr/X11R6/bin/RunWM --FvwmMWM
;;
esac
fi

# Argh! Nothing good is installed. Fall back to fvwm2 (win95-style) or twm
/usr/X11R6/bin/RunWM --Fvwm95 || {
# gosh, neither fvwm95 nor fvwm2 is available;
# fall back to failsafe settings
xclock -geometry 100x100-5+5 &
xterm -geometry 80x50-50+150 &

#4. 이부분은 어떤효과가 나오나요?

if [ -f /usr/bin/netscape -a -f /usr/doc/HTML/index.html ]; then
netscape /usr/doc/HTML/index.html &
fi
if [ -f /usr/X11R6/bin/fvwm ]; then
exec fvwm
else
exec twm
fi
}

#####종료#####

이것도 1~4가지 의문점..

총 8개나되고 소스를 통채로 올려서.. 스크롤하시기 귀찮으시겠지만... 어디 물어볼데도 없고 작은 희망으로나마 이곳에 여쭙니다 ㅠㅠ 굽이 살피셔서 8가지 장벽을 넘을수 있도록 아무쪼록 부탁드립니다...

나름대로 성의껏 질문 올렸는데 그래도 부족한부분은 말씀주세요...

mrjh76의 이미지

일단, startx에 대해서만...

1. 파일이 존재하고 일반 파일이면 참. (man bash)

2. \ 는 뒤의 특수기호 "와 . 을 특수기호가 아니라 문자로 인식시키기 위해서... 그러니까... "로 시작되는 부분과 .로 시작되는 부분을 말함!

3. [0-9]는 정규표현식으로 0~9의 숫자... 그러니까... :와 숫자로 시작되는 부분...

4. 그냥 xauth 명령의 command니까... man xauth 해보면 되죠...

그리고... 두번째.... 후후....

1. -a 는 and로 보면 되죠....

2. 변수 설정하는거예요...

3. 2> 는 에러 출력을 말하는거고... 그것을 /dev/null 로 보낸다... 즉, 에러메세지 보고 싶지 않다.

4. man xclock, man xterm 해보면 되죠... 프로그램에 따른 옵션이니까...

manji의 이미지

정말정말 감사합니다..
많은 도움이 되었습니다..

Prentice의 이미지

man test

http://man.kldp.org/wiki/GetManPage?action=GetManPage&lang=ko&man=test&sec=1

test의 맨페이지를 보시는 것도 도움이 되리라 생각합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.