Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I've tried to run the following bash script:

while [ $x -le 10 ]
    echo "Welcome $x times"
    x = $(( $x + 1))

And when I run it, I get a stream of messages that seem to repeat until I Ctrl-Z it.

im4t:test math4tots$ ./
Welcome 1 times
launch_msg("CheckIn") IPC failure: Operation not permitted
Xquartz: Unable to locate waiting server: org.x.X11
Xquartz: = /Applications/Utilities/
Xquartz: Starting X server: /Applications/Utilities/ --listenonly main(): argc=2
    argv[0] = /Applications/Utilities/
    argv[1] = --listenonly
Waiting for startup parameters via Mach IPC. No launchd socket handed off, unsetting DISPLAY do_start_x11_server(): argc=3
    argv[0] = x
    argv[1] = =
    argv[2] = 2
Unrecognized option: =
use: X [:<display>] [option]
-a #                   default pointer acceleration (factor)
-ac                    disable access control restrictions
-audit int             set audit trail level
-auth file             select authorization file
-br                    create root window with black background
+bs                    enable any backing store support
-bs                    disable any backing store support
-c                     turns off key-click
c #                    key-click volume (0-100)

... Lengthy error message that exceeds 30000 characters ...

ttyxx                  server started from init on /dev/ttyxx
v                      video blanking for screen-saver
-v                     screen-saver without video blanking
-wm                    WhenMapped default backing-store
-wr                    create root window with white background
-maxbigreqsize         set maximal bigrequest size 
+xinerama              Enable XINERAMA extension
-xinerama              Disable XINERAMA extension
-dumbSched             Disable smart scheduling, enable old behavior
-schedInterval int     Set scheduler interval in msec
-sigstop               Enable SIGSTOP based startup
+extension name        Enable extension
-extension name        Disable extension
-query host-name       contact named host for XDMCP
-broadcast             broadcast for XDMCP
-multicast [addr [hops]] IPv6 multicast for XDMCP
-indirect host-name    contact named host for indirect XDMCP
-port port-num         UDP port number to send messages to
-from local-address    specify the local address to connect from
-once                  Terminate server after one session
-class display-class   specify display class to send in manage
-cookie xdm-auth-bits  specify the magic cookie for XDMCP
-displayID display-id  manufacturer display ID for request
[+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ]
                       enable/disable accessx key sequences
-ardelay               set XKB autorepeat delay
-arinterval            set XKB autorepeat interval

Device Dependent Usage:

-depth <8,15,24> : use this bit depth.
-fakebuttons : fake a three button mouse with Command and Option keys.
-nofakebuttons : don't fake a three button mouse.
-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.
-fakemouse3 <modifiers> : fake right mouse button with modifier keys.
  ex: -fakemouse2 "option,shift" = option-shift-click is middle button.
-version : show the server version.

Fatal server error:
Unrecognized option: (null)

[1]+  Stopped                 ./

I also get a window that flickers (closes and opens repeatedly): enter image description here

Also, in case it is relevant, I'm using Mac OS X Lion, but it doesn't seem like it it should matter...

It looked like a harmless enough bash script...

share|improve this question
You "Ctrl-Z" it? You realise that doesn't kill your program, it just stops it temporarily until you restart it again. If you type jobs do you have a bunch of stopped jobs hanging around? – Adrian Pronk Mar 12 '12 at 4:20
@AdrianPronk I don't know if I just timed it wrong, but Ctrl-c didn't seem to work the first time I tried it. However, when I closed the terminal, it asked if I wanted to kill running processes associated with it, so I imagine it died then. – math4tots Mar 12 '12 at 4:50

1 Answer 1

up vote 11 down vote accepted

You have an extra space in this line:

x = $(( $x + 1))

The shell is trying to run the program x, which appears to be an X server (Mac OS's standard file system isn't case sensitive, so I imagine it's actually running X). You need to do this:

x=$(( $x + 1))
share|improve this answer
or even just (( x += 1 )) – glenn jackman Mar 9 '12 at 14:41
or even just (( x++ )); – jordanm Mar 9 '12 at 21:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.