Comments (7)
I messed around in a-shell for a minute. You might try this:
- create a new directory ~/Documents/a-shell-bin
- add that new directory to your PATH environment variable
- create the no-op version of
stty
referenced above by:
$ cd ~/Documents/a-shell-bin
$ cat > stty
#
exit 0
- type Control-D to exit cat and write the file
- change ~/Documents/a-shell-bin to be executable by everyone (i.e.
chmod 755 stty
)
from cmd2.
What operating system are you using? Would you mind posting your simple program? With this info I'll bet I can chase down your problem.
from cmd2.
I am running the program under a-Shell on a iPad Pro with iOS 16.3.1
Here's the code:
import cmd2
def setprompt():
global current_book
promptstr = f"<My Prompt:> "
CmdBooks.prompt = promptstr
class CmdBooks(cmd2.Cmd):
"""Simple Command Processor"""
def default(self, line):
print("Invalid command; try again")
def do_one(self, line):
print("This is command one.")
def do_two(self, line):
print("This is command two.")
if __name__ == "__main__":
CmdBooks().cmdloop()
from cmd2.
Gotcha. Here's what's happening: occasionally control characters in the printed output can mess up your terminal. This only seems to happen on linux/bsd/unix variants. So after each command has run, cmd2
resets the terminal using the stty sane
command. It only tries to execute this if the operating system isn't windows. In all our experience to date, all non-windows operating systems have included the stty
command. I downloaded a-shell
, and sure enough, the kernel identifes itself as darwin (a bsd variant), but there is no stty
command in the default install. So when you run a command cmd2
tries to clean up the terminal, and a-shell
complains because it doesn't include a stty
command.
As for potential solutions, I'm not sure how we could get cmd2
to tell it was running inside of a-shell
. The kernel a-shell
reports looks like macOS to python. So here's some things you could try:
- see if there is a way to install a working
stty
program ina-shell
- create a shell script named
stty
and put it in youra-shell
path. The script would contain something like:
# do nothing
exit 0
That way when cmd2
tries to run stty
it will be able to run it and not generate any error message.
Another alternative might be to try iSH on your ipad. It includes a working stty program.
Hope this helps.
from cmd2.
@kotfu thank you for the help. I have played around with this today and so far haven't been successful in generating a no-op version of stty, but I'm still working on it.
With respect to determining the presence of a-Shell, I had done that for some options in my script. a-Shell has an environment variable $APPDIR that is the location of the a-Shell.app. So I did:
import os
appdir = os.getenv("APPDIR")
if appdir != None and "a-Shell" in appdir:
in_ashell = True
else:
in_ashell = False
For now I have modified the cmd2.py file on my iPad so that it doesn't run stty if I find I am in a-Shell--same as it does if cmd2 is running in Windows.
from cmd2.
Thanks. Before I saw your latest, I compiled a simple C program called stty:
int main(void) {
return(0)
}
I compiled it, put it in ~/Documents/bin, and now unmodified cmd2 doesn't complain when run!
Thanks a lot for helping with this.
from cmd2.
Glad you were able to get it sorted, and it looks like there may be some interest from a-shell in doing something more standard to resolve the issue.
from cmd2.
Related Issues (20)
- Can I call Command Scripts from python code? HOT 1
- Edit auto complete in a specific directory HOT 1
- poutput() and ansi styles.
- tttt HOT 1
- Adding a did you mean? or most similar command in case of error HOT 10
- Typing problem: use of @with_argparser will cause mypy to issue an error HOT 4
- New versions of Statekeeper, ParsedString HOT 3
- Generates an AttributeError when used in a pyinstaller-packaged application HOT 3
- mypy since 1.6.0 introduces validation error
- Allow class member method to be argparse factory
- comments are not stripped when a command is decorated by "cmd2.with_argparser" HOT 1
- onecmd returns False if command returns None, different from cmd module behavior
- Persistent history file not saved when application is killed HOT 2
- how to save the Settable HOT 2
- Can't run first application example HOT 1
- readline history is fragmented when using multiline commands
- vertically help menu HOT 2
- Getting extra quotes when tab autocomplete(behaviour different when compared with cmd) HOT 5
- onecmd throwing RecursionError?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmd2.