Can’t write files
I just installed a-shell and whenever i try an operation that requires write permissions such as touch or mkdir i get an Operation not permitted error. I seem to have the right permissions so i don’t know why this is happening.
[~]$ ls -la
total 8
drwxr-xr-x@ 7 mobile mobile 256 Mar 18 15:32 .
drwxr-xr-x 256 mobile mobile 8192 Dec 31 1969 ..
-rw-r--r-- 1 root mobile 583 Mar 18 15:31 .com.apple.mobile_container_manager.metadata.plist
drwxr-xr-x 2 mobile mobile 64 Mar 18 15:29 Documents
drwxr-xr-x 9 mobile mobile 288 Mar 18 17:05 Library
drwxr-xr-x 2 mobile mobile 96 Mar 18 15:32 StoreKit
drwxr-xr-x 2 mobile mobile 64 Dec 31 1969 SystemData
drwxr-xr-x 5 mobile mobile 160 Mar 19 11:27 tmp
[~]$ whoami
mobile
[~]$ touch test
touch: test: Operation not permitted
Any idea what’s going on and how to fix it?
Hi, that's a specificity of iOS: you cannot write anything in ~, only in ~/Documents/. Just type cd or cd Documents and it will take you to the place where you can write and edit files.
Interesting, there’s no way around that? This means that i can’t edit my .bashrc, is there any fix for that?
All a-Shell commands expect the configuration files to be in ~/Documents/, so ~/Documents/.bashrc will be read at startup (and your SSH keys go in ~/Documents/.ssh, your Vim files in ~/Documents/.vimrc...)
Keep in mind, though, that a-Shell is not bash. The ~/Documents/.bashrc is read while the app is starting up, and executed line by line.
Interesting. This makes it so that scripts I have that reference ~ won’t work in a-shell. I wonder if it’s possible to work around this by aliasing ~ to ~/Documents somehow. Like, you’ve already made that substitution in several places where ~ is used, I wonder if it’s possible to make it in every place, so that for all intents and purposes ~/Documents is the home folder.
I've tried that. The easiest solution is to redefine $HOME to $HOME/Documents, using setenv or export.
The good news is that scripts that use ~ will work unedited, the bad news is that the system (iOS) is also using the value of $HOME (to access the ~/tmp directory, for example), and it will use to the new value. The benefit/costs analysis is something each user has to do on their own.
If you want to adapt your scripts depending on where they are running, you can use the environment variable TERM_PROGRAM, which is defined in all terminals that I know of. In Apple terminals, it is Apple_Terminal, in a-Shell is it a-Shell.