Open Mrlaolu opened 1 month ago
The default shell in a-Shell is highly simplified, both for performance reasons and for historical reasons (backward compatibility). It doesn't have the ability to run two commands on the same line (also, if you enclose the command in quotes, it means you want to run the command "clang++ a.cpp -o a" in a single word, which results in "Command not found").
For advanced stuff, there is another shell (dash), which has more abilities. Your alias might work there. Otherwise, the simplest version is to make a shell script:
#! sh
programname=$1
clang++ $programname.cpp -o $programname
./$programname
It works,Thanks!And I want to know use shortcut key to stop(or kill) a command.(where i can learn all the shortcut keys that a-shell have)
The shortcut keys are the usual ones for a Unix terminal: ^C to stop a program, ^D for harder interupt, ^E to the end of line when editing, ^A for begining of line when editing... They're all based on control + key, unless you have an external keyboard connected.
The catch is that ^C will only send interupt to the program. It's up to the program to listen to that interruption (which is unlikely for small C++ programs). You would need to add a line in your code that checks if there is something new on stdin (without stopping) and stops if that something new is ^C.
like this