holzschu / ios_system Goto Github PK
View Code? Open in Web Editor NEWDrop-in replacement for system() in iOS programs
License: BSD 3-Clause "New" or "Revised" License
Drop-in replacement for system() in iOS programs
License: BSD 3-Clause "New" or "Revised" License
Just that, ctags would be great.
When passing a gibberish string to ios_system, it prints "command not found" to stderr, but returns 0, meaning it was successful. This does not match what other shells do when commands are not found.
I tested Bash and Fish to see what they do, and they both return 127 when no command is found.
And here is an implementation.
https://gist.github.com/yury/66b3e4377a530f6739d2f3327700ee64
Those might be useful too
Travis CI is free for open source projects. Setup is pretty easy, and the benefits are great.
Setup:
• Add .travis.yml file to the root of this project (example: https://github.com/louisdh/terminal/blob/master/.travis.yml)
• Go to https://travis-ci.org, log in with GitHub and enable this project
I found this command useful.
I tried to port it myself this time.
This command is in adv_cmds
, don't find it framework.
so, I test it with in files.framework
And I don't get how to create patch file.
So this is my whois.c file
I hope it helps.
Hi !
I am not able to go around that ‘permission denied’ 👎
Could you give me a hand ?
Thanks for your job !
Regards, François
iPad de François: ls
iPad de François: cd /
cd: /: permission denied
iPad de François: date
Sat Jan 20 13:33:01 CET 2018
iPad de François: ?
awk, cat, cd, chflags, chksum, clear, compress, cp, curl, date, du, echo, egrep, env, fgrep, grep, gunzip, gzip, help, link, ln, ls, mkdir, mv, printenv, pwd, readlink, rm, rmdir, scp, sed, setenv, sftp, stat, sum, tar, touch, tr, uname, uncompress, unsetenv, uptime, wc, whoami
iPad de François: cd ..
cd: ..: permission denied
iPad de François: login
login: command not found
iPad de François: man ls
man: command not found
iPad de François: uname
Darwin
iPad de François: whoami
mobile
iPad de François: cd /var
cd: /var: permission denied
iPad de François: cd /var/mobile
cd: /var/mobile: permission denied
iPad de François: cd /var/mobile/Containers
cd: /var/mobile/Containers: permission denied
iPad de François: cd /var/mobile/Containers/Data
cd: /var/mobile/Containers/Data: permission denied
iPad de François: cd /var/mobile/Containers/Data/Application
cd: /var/mobile/Containers/Data/Application: permission denied
iPad de François:
I want to port all blink commands to ios_system commands.
Simple commands like help
, config
are ok. But some commands, like ssh, mosh need some sort of thread state.
I'm thinking about ios_setContext(void * thread_context)
same as ios_setStreams
. So it would be possible to grab that context inside the commands.
Does it make sense? If idea is acceptable, I can do PR for that.
I think it will be nice :)
I found this command in text_cmds, but did get how to port common crypto part.
Unless I'm doing things wrong here, after checking out the project at master, and running:
get_sources.sh
get_frameworks.sh
I get a bunch of untracked files in git:
ios_system.xcodeproj/xcuserdata/<username>.xcuserdatad
Frameworks/*.framework
curl/*
file_cmds/*
libarchive/*
libinfo/*
libutil/*
shell_cmds/*
text_cmds/*
I would recommend updating the .gitignore
file in the repo to ignore these directories.
I've stepped through the ssh_main method to see why nothing is happening when I run ssh Ian@<ip> pwd
.
I have no SSH keys on my device, and no .ssh
folder.
After checking the userauthlist, rc
= 0. It searches through my ~/Documents
folder in a while loop, and rc
is still 0. On line 537, it checks whether rc
is greater than or equal to zero, and returns if so, without printing any error code.
P.S. "Authentification" is not a word, "Authentication" is.
Method: start awk. Get output. Relaunch awk with the same command. Get output repeated twice.
It works ok on:
echo "welcome" | awk '{ print substr( $0, 0, 4 ) }'
welc
But crashes on:
echo "welcome" | awk '{ print substr( $0, length($0) - 3, length($0) ) }'
Steps to reproduce (tested in OpenTerm):
• ssh-keygen
• enter "test" as passphrase twice
• crashes on strnvis(fmtbuf, msgbuf, sizeof(fmtbuf)
in log.c
Example:
echo 'nice' | ssh host
Currently ios_system
exits after first command (echo nice
) and start second command (ssh host).
But we already show blink>
prompt :)
Hi @holzschu,
I need to send SIGWINCH to main command thread. I tried following code (called on main thread):
pthread_t tid = ios_getLastThreadId(); // result is always 0
pthread_kill(tid, SIGWINCH);
But ios_getLastThreadId()
always return 0.
I'm thinking to add ios_pthread_kill
to send signals to similar to ios_kill
but with pthread_kill
instead of pthread_cancel
. Or I missing something and there is a better way to do that?
Thank you for any help.
Hi,
Originals of this request:
I wanted to link iCloud Drive/Documents
to ~/Documents/iCloud
. My first try was with hard links, but turns out iCloud do not refresh live in that case. Soft link is worked, but if I cd ~/iCloud
I got permission denied if I set miniroot to app/Documents
.
Proposal:
Add ios_setMiniRoots(NSArray<NSString *> *paths)
and use collection of paths to check.
Changing miniroot is not very good option.
So, if you don't mind, I can create PR with that.
I'm getting Use of undeclared identifier 'SORT_VERSION'
when trying to compile the latest ios_system master (with the sort command) in OpenTerm.
I'd suggest building each command as a dynamic library (either .dylib or .framework), and lazy loading them at runtime.
As noted in the README, all the code for all of the commands is loaded into memory at app launch. This seems wasteful & unnecessary, and probably won't scale too well when adding more commands over time.
Additionally, it looks like they are currently being built into a single Xcode target. It'd be great if each command was its own target, with defined inputs/outputs (i.e. build these source files into this dylib). That way it's easier to pick & choose, and scales better.
bc is a very useful calculator app, the most recent version has the gnu license.
There is also a Lucent (Plan 9) version.
Currently, all functions are loaded at startup time in an NSDictionary
, or later added to the dictionary using replaceCommand
. In order to be executed a function must be both:
It would be good to also scan unknown embedded libraries for functions that can be used. This must be done without dlopen
-ing the library, as it would defeat the purpose (dlclose
does not always release the dynamic library).
Something like: nm unknown.dylib | grep _main$
should extract the name of the functions, if it works on a signed library (and if I can find the source of nm
).
Currently, command line parsing in ios_system.m
works with ">", "&>" and "2>&1", all of which erase and open the output file. It would be useful to have ">>" as well, to append to an existing file. Especially with "echo", which can put a marker in the file.
Currently, we can output the result of a command into a file: ls -lhrt > listing
. It would be useful to also have the ability to pipe commands: ls -R | grep .dylib
.
Most of the work is here (inside the commands themselves). What needs to be done:
OpenTerm passes UTF-8 commands to ios_system, and expects UTF-8 output from commands. However, argument parsing & command parsing converts the string to ASCII, which causes data loss.
Try: echo 😀
in OpenTerm to see results.
I just realized I did not pick a license for the common parts of ios_system. The utilities themselves (mkdir, ls, pwd...) are covered by their original license (Free BSD, mostly). But the "glue" code (ios_system.m
and the other files) is currently not covered, which is a very bad idea.
I'm open to suggestions. I'm leaning towards a revised-BSD license (3 clause BSD license).
Those of you who contributed to the code: @yury, @louisdh, @IMcD23, @palmin, @pducks32 : any opinion about the type of license?
Parsing the command line is done for the most common cases (< input
, > output
, &> error
and 2>&1
.
Two things are missing (besides piping, issue #6 and appending, issue #4):
lua fact.lua <<< "9"
2>&1
is before or after > output
. The results are supposed to be different.See https://en.wikipedia.org/wiki/Redirection_(computing) for detailed description.
A full ssh
command is impossible without interactivity (and Blink does it perfectly well already). But a minimalist ssh
that launches a command on the remote site and disconnects (ssh user@host ls -lhrt
) would be useful in several cases (including inside iVim).
Executing the command ~
crashes at line 760 in ios_system.m
.
for (int i = 0; i < argc; i++) free(argv_ref[i]);
Fwiw, any amount of tildes crashes (e.g. ~~~
).
Hello. Do you plan to release a new version? I use pre-built frameworks.
Not sure which OpenSSH we are using, but it'd be great if we could get the ssh-keygen utility to generate SSH keys.
As requested by @yury and @IMcD23 : ios_system() should be made thread-safe, allowing people to launch commands in multiple tabs.
This is not trivial, since making current_command_root_thread
a thread-local variable results in it not being set in most threads, and ios_kill()
having no thread ID available to kill.
Ideally, I'd like an implementation that is compatible with current applications.
Making ios_system itself thread-safe will leave the issue of some commands being not thread-safe themselves (2 "python" in separate tabs will almost certainly not work).
I'm having trouble compiling the latest master
version of iVim
I'm doing the same steps that worked before. The compilation ends with the error message
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
cd /Users/goerz/Documents/Programming/iVim/iVim
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name iVim -Onone -enforce-exclusivity=checked -DDEBUG -sdk [...]
<unknown>:0: error: no such file or directory: '/Users/goerz/Documents/Programming/iVim/iVim/URLRealizer.swift'
<unknown>:0: error: no such file or directory: '/Users/goerz/Documents/Programming/iVim/iVim/ArgumentToken.swift'
<unknown>:0: error: no such file or directory: '/Users/goerz/Documents/Programming/iVim/iVim/URLOpener.swift'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
The swift files it complains about are actually in /Users/goerz/Documents/Programming/iVim/iVim/iVim
(an extra iVim
). I've tried copying the entire content of that directory up one level, to the path where Xcode seems to be asking for.
This gets me further in the compilation, but then the linker fails with
ld: illegal data reference in _Py_NoSiteFlag to thread local variable _Py_NoSiteFlag in dylib /Users/goerz/Documents/Programming/iVim/iVim/Frameworks/Python_ios.framework/Python_ios for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?
The deployment targets of new dylibs that were added are iOS 11.3, which is higher than OpenTerm's. There is no need for them to be so high, and it's causing warnings.
It seems that most everything currently returns 0, even when things fail. The following should be happening:
When a command calls exit(status_code), or its main method returns, store exit code, then call pthread_exit, and return exit code.
Hi @holzschu,
In blink cat known_hosts | bpcopy
works fine, but cat keys | pbcopy
crashes because it tries to set nil
to [UIPasteboard generalPasteboard].string
It is better to collect all input in NSData first, because we can hit incomplete utf-8 char on buffer end.
Here is more safe version:
https://gist.github.com/yury/7a99c559e7b687a861b2f40cba67bbc1
Something in ls
command is not thread safe.
After some time ls -la
output plane text instead of colored. Still can't track it down.
It is listed in commandDictionary.plist. But I could find implementation in network_ios.
I check out the most recent release and try to build the curl_ios_static. But it failed on this. Any ideas why?
I did the get_source.sh
and get_frameworks.sh
.
Thank you.
In the zsh:
ssh localhost "echo nice; ls -la" 1>/dev/null
# outputs nothing
ssh localhost "echo nice; ls -la 1>/dev/null"
nice
In the blink, which is using ios_system for executing commands:
ssh -q office "echo nice; ls -al"1>/dev/null
# outputs nothing
ssh -q office "echo nice; ls -al 1>/dev/null"
zsh:1: unmatched "
This is with a build of your fork of iVIm.
running
:!ls ~/tmp
displays the directory contents, then crashes the app after hitting return.
I think it could be useful.
Use them every day :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.