这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@tareksander
Copy link
Member

I implemented an interface to give Termux:API access to folders via SAF, list those folders, the contents, subfolders, create, delete, read and write files.

I also made a branch in my termux-api-package fork with utilities to use this new interface from the terminal.

This will close #475.

@Grimler91
Copy link
Member

The non-json printed results are printed without a trailing newlines, is that on purpose?

~/projects/termux-api-package $ termux-saf-managedir
content://com.android.externalstorage.documents/tree/primary%3A~/projects/termux-ap

@tareksander
Copy link
Member Author

I thought that would be nice if you capture the output directly into a variable and not get the newline, but a JSON string and after that a newline is fine, too. Should I do that instead?

@agnostic-apollo
Copy link
Member

Yes, newlines should exist for both json and normal string output so that PS1 is not on the same line after command is run. That's how commands normally behave.

Command Substitution like var="$(command)" will automatically trim any newlines, its standard shell behaviour, so not an issue for var capture.

The shell shall expand the command substitution by executing command in a subshell environment (see Shell Execution Environment) and replacing the command substitution (the text of command plus the enclosing "$()" or backquotes) with the standard output of the command, removing sequences of one or more <newline> characters at the end of the substitution. Embedded <newline> characters before the end of the output shall not be removed; however, they may be treated as field delimiters and eliminated during field splitting, depending on the value of IFS and quoting that is in effect. If the output contains any null bytes, the behavior is unspecified.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03

@tareksander
Copy link
Member Author

Fixed that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants