Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Decollete

macrumors newbie
Original poster
May 17, 2010
3
0
Hello. I just recently started using a Mac and I have a simple question I couldn't find over the net.

How do I send the break key in Mac? For example in terminal, if I typed a long line but want to abort it, I used press Ctrl-C to cancel it in a different OS. Or if there is a console application, I press Ctrl-C to force the application to close.

I checked websites which told me to use the following:
command key + C - doesn't work
(I tried shift + command key + C, it also does not work)
alt + F3 (I pressed shift, option [for alt] and f3) - all my windows spread apart from each other
option + F3 - Expose & Spaces configuration window appears

Please help if you know the key. Thanks!
 

forcefieldkid

macrumors 6502
Jan 20, 2010
313
0
Cmnd+Q quits an application.
cmnd+alt+escape brings up the force quit menu where you can select the application and quit it.
 

Decollete

macrumors newbie
Original poster
May 17, 2010
3
0
Thanks for all the replies.
Unfortunately, it does not behave the same way for me.

Mac OS X
Version 10.6.3

Terminal
Version 2.1.1 (273)


Device:
Name: <my name>’s Keyboard
Address: 7c-6d-62-3f-5b-ff
Type: Keyboard
Firmware Version: 0x50
Services: Apple Wireless Keyboard
Paired: Yes
Favorite: No
Connected: Yes
Manufacturer: Apple (0x3, 0x31c)
Vendor ID: 0x5ac
Product ID: 0x23b

If I launch terminal from:
Applications -> Utilities -> Terminal

If I type something, then press command + c keys, nothing happens. I am expecting the line to be broken as if I pressed delete all the way back then return the return key.

Similarly, if I tried to tar a directory, then press command + c keys as it performs the operation, nothing happens.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
If I type something, then press command + c keys, nothing happens. I am expecting the line to be broken as if I pressed delete all the way back then return the return key.

Similarly, if I tried to tar a directory, then press command + c keys as it performs the operation, nothing happens.

Command-C is copy. Control-C is control-C.
 

Hmac

macrumors 68020
May 30, 2007
2,130
4
Midwest USA
Everybody is telling you to use control-c and you are responding by saying that command-c doesn't work.

Try using control-c ?
 

Decollete

macrumors newbie
Original poster
May 17, 2010
3
0
Wow, I completely missed that key. I knew it was not the caps button, but it never occurred to me to even look at what button that is exactly. Thanks!

Edit:
I checked the net for Mac keyboard layouts and found mine to be strange. My caps key is on the same row as option, command, etc. while my control key is on the same row as asdf.
 

levocsamac

macrumors newbie
Feb 9, 2014
1
0
control-c in MAC terminal

new to MAC, had the question in the title, searched google, wound up on this page, found none of the answers were helpful. used MAC terminal help and found (surprisingly)
"Break.......Typing Command-Period (.) is equivalent to entering Control-C on the command line"

It works too.

The disappointing thing is that I've been using windblows for 30 years and linux for 20 and both of them have been using control-c (like CPM did) for good reason. Why would apple need to change it?
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
The disappointing thing is that I've been using windblows for 30 years and linux for 20 and both of them have been using control-c (like CPM did) for good reason. Why would apple need to change it?

The majority of Mac users have never in their life used Control-C. A significant number of Mac users have used Command-period, because that has always been the standard way to stop operations. And those who haven't will never need to learn either.
 

AlanShutko

macrumors 6502a
Jun 2, 2008
804
214
The disappointing thing is that I've been using windblows for 30 years and linux for 20 and both of them have been using control-c (like CPM did) for good reason. Why would apple need to change it?


They didn't. Control C works in terminals. It does not work outside of terminals, just as it does not in Windows or Linux.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,420
A sea of green
new to MAC, had the question in the title, searched google, wound up on this page, found none of the answers were helpful. used MAC terminal help and found (surprisingly)
"Break.......Typing Command-Period (.) is equivalent to entering Control-C on the command line"

It works too.

The disappointing thing is that I've been using windblows for 30 years and linux for 20 and both of them have been using control-c (like CPM did) for good reason. Why would apple need to change it?

The first Mac keyboards didn't have a control key. None at all.

Mac Plus keyboards didn't have a control key, either.

I'd have to look it up, but I don't think an actual control key appeared until the ADB keyboards arrived. I definitely have a control key on an Apple Extended Keyboard II (which is still in regular use, via an ADB-to-USB adapter).
http://en.wikipedia.org/wiki/Apple_Keyboard


The command to interrupt or abort the current operation was usually an "Abort" or "Interrupt" or "Stop" menu-item in a menu. Since it was a menu-item, the convention of assigning it a command-key applied. The conventional command-key was command-period (there was a contemporaneous Apple UI guideline that stated this).


I probably have a very early version of MPW on a CD, and its "interrupt" key is undoubtedly command-period. I could probably dig up an early version of some BBS/terminal program like MacTEP that also uses the command-period convention.

FWIW, BBS programs like MacTEP would often have an option to disable command-key menu-shortcuts, and let all command-keys (e.g. cmd-C, cmd-X, etc.) be interpreted as ctrl-keys by the app.


In any case, now that Apple keyboards have a control key, you can continue using ctrl-C.

I find that I go back and forth between ctrl-C and command-period. The command and period keys are adjacent on all my keyboards, so my right index finger touching my right thumb together can easily produce the keystroke. Obviously, this depends on the keyboard.
 

smithrh

macrumors 68030
Feb 28, 2009
2,722
1,730
I'll further note that Command - period predates both Windows and Linux, so Apple didn't change anything.

Why didn't Microsoft and Linux follow Apple's example, that would be a better question.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,420
A sea of green
I'll further note that Command - period predates both Windows and Linux, so Apple didn't change anything.
Control-C as an abort or interrupt keypress goes back to at least TOPS-10 and TOPS-20, which is roughly the mid to late 1960's:
http://en.wikipedia.org/wiki/Control-C#In_command-line_environments


Why didn't Microsoft and Linux follow Apple's example, that would be a better question.
No command key.

Also see:
http://en.wikipedia.org/wiki/Windows_key
http://en.wikipedia.org/wiki/Menu_key
http://en.wikipedia.org/wiki/Command_key
 

macrumnev

macrumors newbie
Oct 29, 2013
8
0
break a while loop

is there a key that will stop a while loop?

control-c
command-.
break
control-break
none of those work
 

macrumnev

macrumors newbie
Oct 29, 2013
8
0
just the command line

while true; do ping -c 3 yahoo.com; done

I can't stop this. I have to close the terminal to stop it.

In a Mac terminal I can't stop this.

Also,
On a Windows host and a Linux VM, control-c stops it.
On a Mac OSX host and a Linux VM, control-c does not stop it.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,420
A sea of green
just the command line

while true; do ping -c 3 yahoo.com; done

I can't stop this. I have to close the terminal to stop it.

In a Mac terminal I can't stop this.

Also,
On a Windows host and a Linux VM, control-c stops it.
On a Mac OSX host and a Linux VM, control-c does not stop it.

Since the ping command will loop indefinitely by default, try this:
Code:
ping yahoo.com
It will continue to ping until interrupted by control-c or command-period. I see no reason to define a loop external to ping itself.

The way your loop is written, the exit status of ping has no effect on the continuation condition of the loop. That is, when ping is terminated due to interrupt (control-c or command-period), it will exit with a non-zero status it exits with a status of zero (success). Unfortunately, that has no effect on the while statement, whose only condition is the 'true' command, which always returns true (successful exit status).

EDIT
My initial reply was slightly wrong. It turns out that ping exits with a 0 status even when it's been interrupted. This is certainly unconventional when compared to other commands, but it's arguable whether it's a bug.

To test ping, run this, then interrupt it after 5 results by pressing command-period or ctrl-c:
Code:
ping -c 10 google.com; echo " -- status: $?"
In any case, ping will loop indefinitely by itself, so an external loop is superfluous.
 
Last edited:

macrumnev

macrumors newbie
Oct 29, 2013
8
0
First, you didn't read the thread, which asks about stopping something on the command line, then you assume some idiot is working in some language he doesn't know anything about. Then you have some smug comment about "details are important" like I'm a child. Yeah, they are, SO READ THEM.

I don't really care if you see no reason or not to loop a ping, that was the question. If you can't answer a question, then don't. The reason the ping is in there is just a simple filler example to replace my 5 commands that I'm sure you would judge and criticize, so I took those out, and put the ping in. Also, smarty, what if I need the ping count to stay under 4? What if the ping failed every third time? What if I wanted to alternate a 'date' command so I knew exactly when the pings were done instead of 10,000 pings with no time stamps. I might want to increment the payload, or change the intervals. Plenty of reasons, but again, I didn't ask for a tutorial on ping simplification.

Also your other thesis falls apart with the facts at hand. Control-c stops it on Linux VM under a Windows Host, but not under a Mac host in a terminal or Linux VM.
 

dyt1983

macrumors 65816
May 6, 2014
1,365
165
USA USA USA
is there a key that will stop a while loop?

control-c
command-.

none of those work

They do work as pointed out in this thread. If you don't see that they work, then it's just not on the Mac you're trying. Therefore, you should look why it doesn't work on the Mac with which you're having the problem. I suggest your keyboard mappings first:

 -> System Preferences -> Keyboard -> Keyboard -> Modifier Keys

(as pointed out in post #10 in this thread)

Then you have some smug comment about "details are important" like I'm a child. Yeah, they are, SO READ THEM.

To be fair, you didn't include details in your first post in the thread, after it was pointed out that those keys work... so if you include the details, it would help determine what exactly you're doing that isn't working. Your second post did include the details though.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,420
A sea of green
First, you didn't read the thread, which asks about stopping something on the command line, then you assume some idiot is working in some language he doesn't know anything about. Then you have some smug comment about "details are important" like I'm a child. Yeah, they are, SO READ THEM.

I don't really care if you see no reason or not to loop a ping, that was the question. If you can't answer a question, then don't. The reason the ping is in there is just a simple filler example to replace my 5 commands that I'm sure you would judge and criticize, so I took those out, and put the ping in. Also, smarty, what if I need the ping count to stay under 4? What if the ping failed every third time? What if I wanted to alternate a 'date' command so I knew exactly when the pings were done instead of 10,000 pings with no time stamps. I might want to increment the payload, or change the intervals. Plenty of reasons, but again, I didn't ask for a tutorial on ping simplification.

Also your other thesis falls apart with the facts at hand. Control-c stops it on Linux VM under a Windows Host, but not under a Mac host in a terminal or Linux VM.
I did read the thread. In fact, I reread it, including my earlier replies. I also went and read your other posts, few though they were, to see if they shed any light on your experience level or gave insight into what kind of while loop you were referring to. Other than what you posted, I have no way of knowing what you know, or guessing what you might mean.

If you're having trouble with a specific command-line construct, then you need to post it, in the exact form that's causing the problem. Putting in fillers and placeholders may not work. You agreed that details are important, yet you posted an example whose details differed from the command-line you were having problems with.

One reason for posting the exact command-line you're having problems with is to replicate the problem here on my machine, and to study ways of solving the problem. If you post a different problem, then all I can do is to study the problem you posted.

One of the ways to solve problems is to restructure them. That's what I did with the ping example you posted. If you'd posted the actual commands you were having trouble with, I would have studied those. I might not have found a solution, but at least I'd be looking for a solution for what you were actually having a problem with. Since you didn't post it in any of your replies, I can't possibly offer any other ideas for solutions.

To see how ctrl-c or command-dot stops a while loop in the shell, try these:
Code:
while true; do true; done
while true; do false; done
while true; do sleep 5; done
You should see that each of these is interruptible. This suggests the problem isn't with the while/do/done per se, but something else. That's just a guess, since we still don't know exactly what commands you're having trouble with.
 
Last edited:

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
First, you didn't read the thread, which asks about stopping something on the command line, then you assume some idiot is working in some language he doesn't know anything about. Then you have some smug comment about "details are important" like I'm a child. Yeah, they are, SO READ THEM.

Recommended reading: Dale Carnegie, How to Make Friends and Influence People.
 

Wondercow

macrumors 6502a
Aug 27, 2008
559
365
Toronto, Canada
First, you didn't read the thread, which asks about stopping something on the command line, then you assume some idiot is working in some language he doesn't know anything about. Then you have some smug comment about "details are important" like I'm a child. Yeah, they are, SO READ THEM.

I don't really care if you see no reason or not to loop a ping, that was the question. If you can't answer a question, then don't.
You're absolutly right; it's too bad chown33 couldn't just answer the question as that would have been the best, most helpful contribution.

So, please allow me to help: "is there a key that will stop a while loop?"

Yes.

I trust that will satisfy your high standards.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.