You are not logged in.

#1 2009-10-11 02:10:32

matthewbauer
Member
From: /usa/ks
Registered: 2009-07-20
Posts: 86

Xinitrc comes up with syntax error

I was trying this setup for an xinitrc file:

DEFAULT_SESSION=awesome

case $1 in
    kde) exec startkde;;
    xfce4) exec startxfce4;;
    wmaker) exec wmaker;;
    blackbox) exec blackbox;;
    awesome) exec awesome;;
    openbox) exec openbox;;
    musca) exec musca;;
    wmii) exec wmii;;
    enlightenment) exec e16;;
    ratpoison) exec ratpoison;;
    etoile) exec etoile;;
    compiz) exec compiz;;
    ) exec $DEFAULT_SESSION
    *) exec $1;;
esac

Seems like it should work right? Well I guess Bash doesn't like the null case, and throws it out as a syntax error. Anyone know of a way around this?

The reason I wanted to do this is because sometimes I'll just want to add a WM to /etc/slim.conf just to test it out.


Libertarian Arch Linux User

Offline

#2 2009-10-11 03:29:10

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: Xinitrc comes up with syntax error

Two things here.

First you forget the two semi colons after $DEFAULT_SESSION

Second you can test for a null case by doing testing an empty string ''

Ex.

'') exec $DEFAULT_SESSION;;

Website - Blog - arch-home
Arch User since March 2005

Offline

#3 2009-10-11 03:41:02

matthewbauer
Member
From: /usa/ks
Registered: 2009-07-20
Posts: 86

Re: Xinitrc comes up with syntax error

Ok thanks.

But do you need a semicolon after every command? I thought it just used the newline like Python. I think it still works fine.


Libertarian Arch Linux User

Offline

#4 2009-10-11 15:18:59

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: Xinitrc comes up with syntax error

http://tldp.org/LDP/Bash-Beginners-Guid … 07_03.html

Each case is an expression matching a pattern. The commands in the COMMAND-LIST for the first match are executed. The "|" symbol is used for separating multiple patterns, and the ")" operator terminates a pattern list. Each case plus its according commands are called a clause. Each clause must be terminated with ";;". Each case statement is ended with the esac statement.


M*cr*s*ft: Who needs quality when you have marketing?

Offline

Board footer

Powered by FluxBB